You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2021/12/06 15:00:06 UTC

svn commit: r1895626 - in /poi/trunk: build.gradle poi/src/test/java/org/apache/poi/poifs/dev/TestPOIFSDump.java

Author: centic
Date: Mon Dec  6 15:00:06 2021
New Revision: 1895626

URL: http://svn.apache.org/viewvc?rev=1895626&view=rev
Log:
Some more changes for early support for JDK 18

Adjust one test which fails with JDK 18 because of
remove SecurityManager
Adjust excludes for JaCoCo as it does not run on JDK 18 otherwise
Adjust some JPMS settings which are not available any more on JDK 18

Some other things do not work yet, e.g. spotbugs

Also print out if CIBuild is selected
Only run signing if actually publishing to avoid failures
if signing key is defined locally

Modified:
    poi/trunk/build.gradle
    poi/trunk/poi/src/test/java/org/apache/poi/poifs/dev/TestPOIFSDump.java

Modified: poi/trunk/build.gradle
URL: http://svn.apache.org/viewvc/poi/trunk/build.gradle?rev=1895626&r1=1895625&r2=1895626&view=diff
==============================================================================
--- poi/trunk/build.gradle (original)
+++ poi/trunk/build.gradle Mon Dec  6 15:00:06 2021
@@ -286,29 +286,30 @@ subprojects {
         isCIBuild |= Boolean.valueOf(System.getenv("CI_BUILD"));
 
         if (isCIBuild) {
-        	jvmArgs += [
-        	    // Strictly serial
-        	    // '-Djunit.jupiter.execution.parallel.enabled=false',
-
-        	    // OR parallel on 2 threads
-				'-Djunit.jupiter.execution.parallel.config.strategy=fixed',
-				'-Djunit.jupiter.execution.parallel.config.fixed.parallelism=2'
-			]
-			maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
-		} else {
-			jvmArgs += [
-			    '-Djunit.jupiter.execution.parallel.enabled=true',
-			    '-Djunit.jupiter.execution.parallel.config.strategy=dynamic',
+            System.out.println("Run with reduced parallelism for CI build");
 
-                // this setting breaks the test builds, do not use it!
-				//'-Djunit.jupiter.execution.parallel.mode.default=concurrent'
-			]
+            jvmArgs += [
+                // Strictly serial
+                // '-Djunit.jupiter.execution.parallel.enabled=false',
+
+                // OR parallel on 2 threads
+                '-Djunit.jupiter.execution.parallel.config.strategy=fixed',
+                '-Djunit.jupiter.execution.parallel.config.fixed.parallelism=2'
+            ]
+            maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
+        } else {
+            jvmArgs += [
+                '-Djunit.jupiter.execution.parallel.enabled=true',
+                '-Djunit.jupiter.execution.parallel.config.strategy=dynamic',
 
-			 // Explicitly defining the maxParallelForks was always slower than not setting it
-			 // So we leave this to Gradle itself, which seems to be very smart
-			 // maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
-			 // maxParallelForks = Math.max( Runtime.runtime.availableProcessors() - 1, 1 )
+                // this setting breaks the test builds, do not use it!
+                //'-Djunit.jupiter.execution.parallel.mode.default=concurrent'
+            ]
 
+             // Explicitly defining the maxParallelForks was always slower than not setting it
+             // So we leave this to Gradle itself, which seems to be very smart
+             // maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
+             // maxParallelForks = Math.max( Runtime.runtime.availableProcessors() - 1, 1 )
         }
 
         // show standard out and standard error of the test JVM(s) on the console
@@ -324,11 +325,16 @@ subprojects {
 
         doFirst {
             if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
-                jvmArgs += [
-                    '-Dsun.reflect.debugModuleAccessChecks=true',
-                    '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true',
-                    '--illegal-access=warn',
+                // some options were removed in JDK 18
+                if (JavaVersion.current().ordinal() < JavaVersion.VERSION_18.ordinal()) {
+                    jvmArgs += [
+                        '--illegal-access=warn',
+                    ]
+                } else {
+                    System.out.println("Configuring for JDK 18 or higher")
+                }
 
+                jvmArgs += [
                     // see https://github.com/java9-modularity/gradle-modules-plugin/issues/97
                     // opposed to the recommendation there, it doesn't work to add ... to the dependencies
                     // testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.1'
@@ -336,9 +342,20 @@ subprojects {
                     '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=org.apache.poi.poi',
                     '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED',
                     '--add-exports','org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED',
+
+                    '-Dsun.reflect.debugModuleAccessChecks=true',
+                    '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true',
                 ]
             }
         }
+
+        jacoco {
+            excludes = [
+                // this is necessary to make JaCoCo work with JDK 18 for now
+                'sun/**',
+                'javax/**',
+            ]
+        }
     }
 
     jacoco {
@@ -478,6 +495,11 @@ subprojects {
     }
 
     signing {
+        setRequired {
+            // signing is only required if this is a release version
+            // and the artifacts are to be published
+            gradle.taskGraph.allTasks.any { it instanceof PublishToMavenRepository }
+        }
         sign publishing.publications.POI
     }
     signPOIPublication.dependsOn('generatePomFileForPOIPublication')

Modified: poi/trunk/poi/src/test/java/org/apache/poi/poifs/dev/TestPOIFSDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/poifs/dev/TestPOIFSDump.java?rev=1895626&r1=1895625&r2=1895626&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/poifs/dev/TestPOIFSDump.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/poifs/dev/TestPOIFSDump.java Mon Dec  6 15:00:06 2021
@@ -29,15 +29,16 @@ import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.security.Permission;
 
+import org.apache.commons.io.output.NullPrintStream;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.poifs.filesystem.NotOLE2FileException;
 import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.property.PropertyTable;
-import org.apache.commons.io.output.NullPrintStream;
 import org.apache.poi.util.TempFile;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
@@ -151,6 +152,9 @@ public class TestPOIFSDump {
 
     @Test
     void testMainNoArgs() {
+        Assumptions.assumeFalse(System.getProperty("java.version").startsWith("18"),
+                "SecurityManager does not work any more since JDK 18");
+
         SecurityManager sm = System.getSecurityManager();
         try {
             System.setSecurityManager(new SecurityManager() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org