You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/12/14 19:20:43 UTC

[groovy] branch master updated: Build with JDK20 ea

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 39a424202c Build with JDK20 ea
39a424202c is described below

commit 39a424202c9a184032e3ad631f34a580079179ba
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu Dec 15 01:19:15 2022 +0800

    Build with JDK20 ea
---
 .github/workflows/groovy-build-test-ea.yml         |  2 +-
 .../groovy/classgen/GenericsGenTest.groovy         |  3 ++-
 .../groovy/groovysh/commands/DocCommand.groovy     | 27 +++++++++++++---------
 .../groovy/groovysh/commands/DocCommandTest.groovy |  7 ++++--
 4 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/groovy-build-test-ea.yml b/.github/workflows/groovy-build-test-ea.yml
index d4a86698fd..715edac4f6 100644
--- a/.github/workflows/groovy-build-test-ea.yml
+++ b/.github/workflows/groovy-build-test-ea.yml
@@ -28,7 +28,7 @@ jobs:
         os: [ubuntu-20.04]
         java: [17]
         # The jdk links of "install-jdk.sh" are sometimes outdated, so we have to download openjdk releases from https://jdk.java.net/ by ourselves.
-        jdk: ["https://download.java.net/java/GA/jdk19/877d6127e982470ba2a7faa31cc93d04/36/GPL/openjdk-19_linux-x64_bin.tar.gz"]
+        jdk: ["https://download.java.net/java/early_access/jdk20/27/GPL/openjdk-20-ea+27_linux-x64_bin.tar.gz"]
     runs-on: ${{ matrix.os }}
     steps:
       - name: Download JDK ${{ matrix.jdk }}
diff --git a/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy b/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
index a002166108..cd7906045b 100644
--- a/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/GenericsGenTest.groovy
@@ -67,7 +67,8 @@ class GenericsGenTest extends GroovyTestCase {
         config.targetDirectory = createTempDir("groovy-target-", "-target")
         config.jointCompilationOptions = [
                 "stubDir": createTempDir("groovy-stub-", "-stub"),
-                "namedValues": ["target", "1.7", "source", "1.7"] as String[]
+                // source version 7 and target version 7 are no longer supported since JDK20. Use 8+
+                "namedValues": ["target", "1.8", "source", "1.8"] as String[]
         ]
         config.classpath = "build/classes"
         FileSystemCompiler compiler = new FileSystemCompiler(config)
diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/DocCommand.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/DocCommand.groovy
index 2f1bfb337a..f3c976d14c 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/DocCommand.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/DocCommand.groovy
@@ -144,23 +144,22 @@ class DocCommand extends CommandSupport {
         String groovyVersion = GroovySystem.version
         String path = className.replace('.', '/') + '.html'
 
+        def url
         def urls = []
         if (!module && className.matches(/^(groovy|org\.codehaus\.groovy|org\.apache\.groovy|)\..+/)) {
-            def url = new URL("https://docs.groovy-lang.org/$groovyVersion/html/gapi/$path")
-            if (sendHEADRequest(url, path)) {
+            if (sendHEADRequest(url = new URL("https://docs.groovy-lang.org/$groovyVersion/html/gapi/$path"), path)) {
                 urls << url
             }
         }
         // Don't specify package names to not depend on a specific version of Java SE.
         // Java SE includes non-java(x) packages such as org.w3m.*, org.omg.*. org.xml.* for now
         // and new packages might be added in the future.
-        def url = new URL("https://docs.oracle.com/${versionPrefix(module)}/$path")
-        if (sendHEADRequest(url, path)) {
+        if (sendHEADRequest(url = new URL("https://docs.oracle.com/${versionPrefix(module)}/$path"), path) ||
+            sendHEADRequest(url = new URL("https://download.java.net/java/early_access/${versionPrefix(module, true)}/$path"), path)) {
             urls << url
         } else if (!module) {
             // if no module specified, fall back to JDK8 if java.base url wasn't found
-            url = new URL("https://docs.oracle.com/javase/8/docs/api/$path")
-            if (sendHEADRequest(url, path)) {
+            if (sendHEADRequest(url = new URL("https://docs.oracle.com/javase/8/docs/api/$path"), path)) {
                 urls << url
             }
         }
@@ -168,28 +167,30 @@ class DocCommand extends CommandSupport {
         if (PRIMITIVES.any{path.startsWith(it) }) {
             path = "primitives-and-primitive-arrays/$path"
         }
-        url = new URL("https://docs.groovy-lang.org/$groovyVersion/html/groovy-jdk/$path")
-        if (sendHEADRequest(url, path)) {
+
+        if (sendHEADRequest(url = new URL("https://docs.groovy-lang.org/$groovyVersion/html/groovy-jdk/$path"), path)) {
             urls << url
         }
 
         urls
     }
 
-    private static versionPrefix(String module) {
+    private static versionPrefix(String module, boolean ea = false) {
         String javaVersion = System.getProperty('java.version')
         if (javaVersion.startsWith('1.')) {
             'javase/' + javaVersion.split(/\./)[1] + '/docs/api'
         } else {
             // java 9 and above
             def mod = module ?: 'java.base'
-            'en/java/javase/' + javaVersion.replaceAll(/-.*/, '').split(/\./)[0] + "/docs/api/$mod"
+            def ver = javaVersion.replaceAll(/-.*/, '').split(/\./)[0]
+            "${(ea ? 'jdk' : 'en/java/javase/')}$ver/docs/api/$mod"
         }
     }
 
     protected boolean sendHEADRequest(URL url, String path = null) {
+        HttpURLConnection conn = null
         try {
-            HttpURLConnection conn = url.openConnection() as HttpURLConnection
+            conn = url.openConnection() as HttpURLConnection
             conn.requestMethod = 'HEAD'
             conn.connectTimeout = TIMEOUT_CONN
             conn.readTimeout = TIMEOUT_READ
@@ -201,6 +202,10 @@ class DocCommand extends CommandSupport {
             return code == 200 && successfulRedirect
         } catch (IOException e) {
             fail "Sending a HEAD request to $url failed (${e}). Please check your network settings."
+        } finally {
+            if (null != conn) {
+                conn.disconnect()
+            }
         }
     }
 
diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/DocCommandTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/DocCommandTest.groovy
index 1ce13d17c9..0d239e3f3e 100644
--- a/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/DocCommandTest.groovy
+++ b/subprojects/groovy-groovysh/src/test/groovy/org/apache/groovy/groovysh/commands/DocCommandTest.groovy
@@ -43,8 +43,8 @@ class DocCommandTest extends CommandTestSupport {
 
         // explicit module given
         urls = command.urlsFor('org.ietf.jgss.GSSContext', 'java.security.jgss')
-        assert urls ==
-            [new URL("https://docs.oracle.com/en/java/javase/${simpleJavaVersion()}/docs/api/java.security.jgss/org/ietf/jgss/GSSContext.html")]
+        assert urls == [new URL("https://docs.oracle.com/en/java/javase/${simpleJavaVersion()}/docs/api/java.security.jgss/org/ietf/jgss/GSSContext.html")] ||
+               urls == [new URL("https://download.java.net/java/early_access/jdk${simpleJavaVersion()}/docs/api/java.security.jgss/org/ietf/jgss/GSSContext.html")]
     }
 
     void testUrlsForJavaClass() {
@@ -54,6 +54,9 @@ class DocCommandTest extends CommandTestSupport {
 
         assert urls ==
                 [new URL("https://docs.oracle.com/en/java/javase/${simpleJavaVersion()}/docs/api/java.base/java/util/List.html"),
+                 new URL("https://docs.groovy-lang.org/$GroovySystem.version/html/groovy-jdk/java/util/List.html")] ||
+               urls ==
+                [new URL("https://download.java.net/java/early_access/jdk${simpleJavaVersion()}/docs/api/java.base/java/util/List.html"),
                  new URL("https://docs.groovy-lang.org/$GroovySystem.version/html/groovy-jdk/java/util/List.html")]
     }