Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2021-11-16 13:31:55 +0000
committerEd Merks2021-11-16 13:31:55 +0000
commit5d63aa61c30125f5f63146a8092ea6501a978a01 (patch)
tree282efbe1908329b8de967dc0469e1bc9aa3929d4
parentbd0bd533dff6e987bd769cd69e6c02a7bf814888 (diff)
downloadjustj.tools-5d63aa61c30125f5f63146a8092ea6501a978a01.tar.gz
justj.tools-5d63aa61c30125f5f63146a8092ea6501a978a01.tar.xz
justj.tools-5d63aa61c30125f5f63146a8092ea6501a978a01.zip
[Releng] Create an indexer to generate Temurim URLs
The generated results can be pasted into the Jenkins pipeline that is for generating JREs.
-rw-r--r--plugins/org.eclipse.justj.codegen/src/org/eclipse/justj/codegen/model/util/TemurinIndexer.java152
1 files changed, 152 insertions, 0 deletions
diff --git a/plugins/org.eclipse.justj.codegen/src/org/eclipse/justj/codegen/model/util/TemurinIndexer.java b/plugins/org.eclipse.justj.codegen/src/org/eclipse/justj/codegen/model/util/TemurinIndexer.java
new file mode 100644
index 0000000..fb16036
--- /dev/null
+++ b/plugins/org.eclipse.justj.codegen/src/org/eclipse/justj/codegen/model/util/TemurinIndexer.java
@@ -0,0 +1,152 @@
+/**
+ * Copyright (c) 2021 Eclipse contributors and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.justj.codegen.model.util;
+
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.osgi.framework.Version;
+
+
+public class TemurinIndexer
+{
+
+ static final Pattern TAG_NAME = Pattern.compile("\"name\"\\s*:\\s*\"(jdk-([0-9.]+)\\+([0-9]+))\"");
+
+ static final Pattern JDK_URL1 = Pattern.compile(
+ "href=\"/adoptium/temurin([0-9]+)-binaries/releases/download/jdk-([0-9]+)%2B35/OpenJDK([0-9]+)-jdk_([^_]+)_([^_]+)_hotspot_([0-9.]+)\\.(tar.gz|zip)\"");
+
+ static final Pattern JDK_URL = Pattern.compile(//
+ "href=\"/(adoptium/temurin[0-9]+-binaries/releases/download/jdk-[^/]+/OpenJDK[^-]+-jdk_[^\"]*\\.(zip|tar.gz))\"");
+
+ public static void main(String[] args) throws Exception
+ {
+ System.out.println("// Generated by /org.eclipse.justj.codegen/src/org/eclipse/justj/codegen/model/util/TemurinIndexer.java");
+
+ for (String repo : new String []{ "11", "17" })
+ {
+ URL url = new URL("https://api.github.com/repos/adoptium/temurin" + repo + "-binaries/tags");
+ try (InputStream input = url.openStream())
+ {
+ List<String> lines = new BufferedReader(new InputStreamReader(input)).lines().collect(Collectors.toList());
+ Map<Version, String> versionTags = new TreeMap<>(Comparator.reverseOrder());
+ for (String line : lines)
+ {
+ for (Matcher matcher = TAG_NAME.matcher(line); matcher.find();)
+ {
+ versionTags.put(Version.parseVersion(Version.parseVersion(matcher.group(2)).toString() + "." + matcher.group(3)), matcher.group(1));
+ }
+ }
+
+ System.out.println();
+ System.out.println("// Tags " + versionTags.values().stream().collect(Collectors.joining(", ")));
+
+ String latest = versionTags.entrySet().iterator().next().getValue();
+ URL downloadsURL = new URL("https://github.com/adoptium/temurin" + repo + "-binaries/releases/tag/" + latest);
+ List<String> jdkDownloadURLs = new ArrayList<>();
+ try (InputStream download = downloadsURL.openStream())
+ {
+ List<String> downloads = new BufferedReader(new InputStreamReader(download)).lines().collect(Collectors.toList());
+ for (String downloadLine : downloads)
+ {
+ for (Matcher matcher = JDK_URL.matcher(downloadLine); matcher.find();)
+ {
+ jdkDownloadURLs.add("https://github.com/" + matcher.group(1).replace("%2B", "+"));
+ }
+ }
+ }
+
+ System.out.println("def java" + repo + "Adoptium = [");
+ System.out.println(" label: 'Java " + repo + " (Adoptium)',");
+ System.out.println(" BUILD_DESCRIPTION: 'Build Adoptium Java " + repo + "',");
+ System.out.println(" PUBLISH_LOCATION_PREFIX: \"${defaultPrefix}\",");
+ System.out.println(" JUSTJ_MANIFEST_URL: \"${justjURL}/${defaultPrefix}/" + repo + "/downloads/latest/justj.manifest\",");
+ System.out.println(" JDK_URLS_WINDOWS: '''");
+ {
+ String jdkURL = getURL(jdkDownloadURLs, "x64_windows");
+ if (jdkURL != null)
+ {
+ System.out.println(" " + jdkURL);
+ }
+ }
+ System.out.println(" ''',");
+
+ System.out.println(" JDK_URLS_MACOS: '''");
+ {
+ String jdkURL = getURL(jdkDownloadURLs, "x64_mac");
+ if (jdkURL != null)
+ {
+ System.out.println(" " + jdkURL);
+ }
+ }
+ System.out.println(" ''',");
+
+ System.out.println(" JDK_URLS_MACOS_AARCH64: '''");
+ {
+ String jdkURL = getURL(jdkDownloadURLs, "aarch64_mac");
+ if (jdkURL != null)
+ {
+ System.out.println(" " + jdkURL);
+ }
+ }
+ System.out.println(" ''',");
+
+ System.out.println(" JDK_URLS_LINUX: '''");
+ {
+ String jdkURL = getURL(jdkDownloadURLs, "x64_linux");
+ if (jdkURL != null)
+ {
+ System.out.println(" " + jdkURL);
+ }
+ }
+ System.out.println(" ''',");
+
+ System.out.println(" JDK_URLS_LINUX_AARCH64: '''");
+ {
+ String jdkURL = getURL(jdkDownloadURLs, "aarch64_linux");
+ if (jdkURL != null)
+ {
+ System.out.println(" " + jdkURL);
+ }
+ }
+ System.out.println(" ''',");
+
+ System.out.println(" BUILD_TYPE: 'nightly',");
+ System.out.println(" PROMOTE: 'true'");
+ System.out.println("]");
+ }
+ }
+ }
+
+ private static String getURL(List<String> downloadURLs, String type)
+ {
+ for (String downloadURL : downloadURLs)
+ {
+ if (downloadURL.contains(type))
+ {
+ return downloadURL;
+ }
+ }
+
+ return null;
+ }
+}

Back to the top