You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "JeremiahDJordan (via GitHub)" <gi...@apache.org> on 2026/05/05 15:36:49 UTC

Re: [PR] CASSANDRA-21344: Add gradle build support [cassandra]

JeremiahDJordan commented on code in PR #4778:
URL: https://github.com/apache/cassandra/pull/4778#discussion_r3189706110


##########
buildSrc/src/main/groovy/JdkJvmArgs.groovy:
##########
@@ -0,0 +1,233 @@
+/**
+ * Provides JDK-version-specific JVM arguments for compilation, runtime, and testing.
+ * Mirrors the flag lists from build.xml ({@code _jvm11_arg_items}, {@code _jvm17_arg_items}, etc.).
+ */
+class JdkJvmArgs {
+
+    /**
+     * {@code --add-exports} flags required by javac (from build.xml {@code jdk11plus-javac-exports}).
+     */
+    static List<String> javacExports() {
+        return [
+            '--add-exports', 'java.rmi/sun.rmi.registry=ALL-UNNAMED',
+            '--add-exports', 'java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED',
+            '--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED',
+            '--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED',
+            '--add-exports', 'java.management/com.sun.jmx.remote.security=ALL-UNNAMED',
+        ]
+    }
+
+    /**
+     * JDK-specific {@code --add-exports} / {@code --add-opens} for runtime JVM args.
+     * Mirrors {@code _jvm11_arg_items}, {@code _jvm17_arg_items}, {@code _jvm21_arg_items}.
+     */
+    static List<String> jvmArgs(int jdkVersion) {
+        switch (jdkVersion) {
+            case 11: return jvm11Args()
+            case 17: return jvm17Args()
+            case 21: return jvm21Args()
+            default:
+                // For unknown/newer JDKs, fall back to JDK 21 args
+                return jvm21Args()
+        }
+    }
+
+    /**
+     * JDK-specific test JVM args.
+     * Mirrors {@code _jvm11_test_arg_items}, {@code _jvm17_test_arg_items}, {@code _jvm21_test_arg_items}.
+     */
+    static List<String> testArgs(int jdkVersion) {
+        switch (jdkVersion) {
+            case 11: return jvm11TestArgs()
+            case 17: return jvm17TestArgs()
+            case 21: return jvm21TestArgs()
+            default:
+                return jvm21TestArgs()
+        }
+    }
+
+    /**
+     * Detect the major version of the running JDK.
+     */
+    static int detectJdkVersion() {
+        String specVersion = System.getProperty('java.specification.version')
+        if (specVersion.contains('.')) {
+            // Pre-JDK 9 format: "1.8"
+            return specVersion.split('\\.')[1] as int
+        }
+        return specVersion as int
+    }
+
+    // -------------------------------------------------------------------------
+    // JDK 11 runtime args (from build.xml _jvm11_arg_items)
+    // -------------------------------------------------------------------------
+    private static List<String> jvm11Args() {
+        return [

Review Comment:
   Can these be read from ant?  Maybe moved into some common properties files?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org