Skip to content

Commit

Permalink
[site] update download links with last release + ensure the download …
Browse files Browse the repository at this point in the history
…links are properly sorted - parallelism was breaking it
  • Loading branch information
rmannibucau committed Aug 21, 2023
1 parent 26021a2 commit acc7fe5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 48 deletions.
3 changes: 2 additions & 1 deletion documentation/src/content/downloads.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ License under Apache License v2 (ALv2).
[.table.table-bordered,options="header"]
|===
|Name|Version|Date|Size|Type|Links
|Arthur Source Release|1.0.6|2022-04-21 20:37:59|575 kB|zip|https://repo.maven.apache.org/maven2/org/apache/geronimo/arthur/arthur/1.0.6/arthur-1.0.6-source-release.zip[icon:download[] zip] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.6/arthur-1.0.6-source-release.zip.sha1[icon:download[] sha1] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.6/arthur-1.0.6-source-release.zip.asc[icon:download[] asc]
|Arthur Source Release|1.0.7|2023-08-18 14:45:58|576 kB|zip|https://repo.maven.apache.org/maven2/org/apache/geronimo/arthur/arthur/1.0.7/arthur-1.0.7-source-release.zip[icon:download[] zip] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.7/arthur-1.0.7-source-release.zip.sha1[icon:download[] sha1] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.7/arthur-1.0.7-source-release.zip.asc[icon:download[] asc]
|Arthur Source Release|1.0.6|2023-04-17 18:37:59|575 kB|zip|https://repo.maven.apache.org/maven2/org/apache/geronimo/arthur/arthur/1.0.6/arthur-1.0.6-source-release.zip[icon:download[] zip] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.6/arthur-1.0.6-source-release.zip.sha1[icon:download[] sha1] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.6/arthur-1.0.6-source-release.zip.asc[icon:download[] asc]
|Arthur Source Release|1.0.5|2022-02-14 17:00:24|574 kB|zip|https://repo.maven.apache.org/maven2/org/apache/geronimo/arthur/arthur/1.0.5/arthur-1.0.5-source-release.zip[icon:download[] zip] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.5/arthur-1.0.5-source-release.zip.sha1[icon:download[] sha1] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.5/arthur-1.0.5-source-release.zip.asc[icon:download[] asc]
|Arthur Source Release|1.0.4|2022-01-26 10:47:39|573 kB|zip|https://repo.maven.apache.org/maven2/org/apache/geronimo/arthur/arthur/1.0.4/arthur-1.0.4-source-release.zip[icon:download[] zip] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.4/arthur-1.0.4-source-release.zip.sha1[icon:download[] sha1] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.4/arthur-1.0.4-source-release.zip.asc[icon:download[] asc]
|Arthur Source Release|1.0.3|2021-08-30 15:08:48|573 kB|zip|https://repo.maven.apache.org/maven2/org/apache/geronimo/arthur/arthur/1.0.3/arthur-1.0.3-source-release.zip[icon:download[] zip] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.3/arthur-1.0.3-source-release.zip.sha1[icon:download[] sha1] https://repository.apache.org/content/repositories/releases/org/apache/geronimo/arthur/arthur/1.0.3/arthur-1.0.3-source-release.zip.asc[icon:download[] asc]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
Expand Down Expand Up @@ -70,10 +71,9 @@ public void update(final PrintStream stream) {
.map(v -> v.extensions("zip"))
.map(v -> v.classifiers("source-release"))
.flatMap(this::toDownloadable)
.parallel()
.map(this::fillDownloadable)
.filter(Objects::nonNull)
.sorted(this::compareVersions)
.sorted(Comparator.<Download, Instant>comparing(it -> it.date).reversed())
.map(it -> toDownloadLine(dateFormatter, it))
.forEach(stream::println);
stream.println("|===\n");
Expand All @@ -91,51 +91,6 @@ private String toDownloadLine(final DateTimeFormatter dateFormatter, final Downl
d.asc + "[icon:download[] asc]";
}

private int compareVersions(final Download o1, final Download o2) {
final int versionComp = o2.version.compareTo(o1.version);
if (versionComp != 0) {
if (o2.version.startsWith(o1.version) && o2.version.contains("-M")) { // milestone
return -1;
}
if (o1.version.startsWith(o2.version) && o1.version.contains("-M")) { // milestone
return 1;
}

final String[] v1 = o1.version.split("\\.");
final String[] v2 = o2.version.split("\\.");
for (int i = 0; i < Math.max(v1.length, v2.length); i++) {
if (v1.length == i) {
return 1;
}
if (v2.length == i) {
return -1;
}
try {
final int diff = Integer.parseInt(v2[i]) - Integer.parseInt(v1[i]);
if (diff != 0) {
return diff;
}
} catch (final NumberFormatException nfe) {
break; // use plain string comparison
}
}

return versionComp;
}

final int nameComp = o1.name.compareTo(o2.name);
if (nameComp != 0) {
return nameComp;
}

final long dateComp = o2.date.compareTo(o1.date);
if (dateComp != 0) {
return (int) dateComp;
}

return o1.url.compareTo(o2.url);
}

private void printHeader(final PrintStream stream) {
stream.println(
"////\n" +
Expand Down

0 comments on commit acc7fe5

Please sign in to comment.