You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2023/12/01 18:42:10 UTC

(logging-log4j2) branch 2.x-java-17 updated: Fix Java 8 test runs

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

vy pushed a commit to branch 2.x-java-17
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/2.x-java-17 by this push:
     new a42283bd50 Fix Java 8 test runs
a42283bd50 is described below

commit a42283bd506bcf61b0d1eba521852c4789e9eb9a
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Fri Dec 1 19:41:33 2023 +0100

    Fix Java 8 test runs
---
 log4j-1.2-api/pom.xml   | 45 ++++++++++++++++++++++++++++++++++++---------
 log4j-core-test/pom.xml | 49 ++++++++++++++++++++++++++++++++++++++-----------
 log4j-jpa/pom.xml       | 45 ++++++++++++++++++++++++++++++++++++---------
 log4j-osgi-test/pom.xml | 39 +++++++++++++++++++++++++++++++++++++--
 4 files changed, 147 insertions(+), 31 deletions(-)

diff --git a/log4j-1.2-api/pom.xml b/log4j-1.2-api/pom.xml
index e47c17ac0c..09ef006194 100644
--- a/log4j-1.2-api/pom.xml
+++ b/log4j-1.2-api/pom.xml
@@ -141,15 +141,6 @@
   <build>
     <plugins>
 
-      <!-- Relax reflective access constraints for tests -->
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <argLine>--add-opens java.base/java.io=ALL-UNNAMED</argLine>
-        </configuration>
-      </plugin>
-
       <!-- Enable Log4j plugin processing -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -168,4 +159,40 @@
     </plugins>
   </build>
 
+  <profiles>
+
+    <!-- Relax reflective access constraints for tests -->
+    <profile>
+
+      <id>reflective-access-fixes</id>
+
+      <!-- CI uses Java 8 for running tests.
+           Though illegal access is disabled by default in Java 16 due to JEP-396.
+           Hence, we assume CI=Java8 and open modules only elsewhere.
+
+           One might think why not activate using `<jdk>[16,)` instead?
+           This doesn't work, since the match is not against "the JDK used by tests".
+           See `java8-tests` profile in `/pom.xml` for details. -->
+      <activation>
+        <property>
+          <name>!env.CI</name>
+        </property>
+      </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <argLine>--add-opens java.base/java.io=ALL-UNNAMED</argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+
+    </profile>
+
+  </profiles>
+
 </project>
diff --git a/log4j-core-test/pom.xml b/log4j-core-test/pom.xml
index e3329cb034..bc48791c98 100644
--- a/log4j-core-test/pom.xml
+++ b/log4j-core-test/pom.xml
@@ -361,17 +361,6 @@
   <build>
     <plugins>
 
-      <!-- Relax reflective access constraints for tests -->
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <argLine>--add-opens java.base/java.lang=ALL-UNNAMED
-            --add-opens java.base/java.net=ALL-UNNAMED
-            --add-opens java.base/java.util=ALL-UNNAMED</argLine>
-        </configuration>
-      </plugin>
-
       <!-- Enable Log4j plugin processing -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -390,4 +379,42 @@
     </plugins>
   </build>
 
+  <profiles>
+
+    <!-- Relax reflective access constraints for tests -->
+    <profile>
+
+      <id>reflective-access-fixes</id>
+
+      <!-- CI uses Java 8 for running tests.
+           Though illegal access is disabled by default in Java 16 due to JEP-396.
+           Hence, we assume CI=Java8 and open modules only elsewhere.
+
+           One might think why not activate using `<jdk>[16,)` instead?
+           This doesn't work, since the match is not against "the JDK used by tests".
+           See `java8-tests` profile in `/pom.xml` for details. -->
+      <activation>
+        <property>
+          <name>!env.CI</name>
+        </property>
+      </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <argLine>--add-opens java.base/java.lang=ALL-UNNAMED
+                --add-opens java.base/java.net=ALL-UNNAMED
+                --add-opens java.base/java.util=ALL-UNNAMED</argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+
+    </profile>
+
+  </profiles>
+
 </project>
diff --git a/log4j-jpa/pom.xml b/log4j-jpa/pom.xml
index 38ec7de69a..df7a007434 100644
--- a/log4j-jpa/pom.xml
+++ b/log4j-jpa/pom.xml
@@ -101,15 +101,6 @@
   <build>
     <plugins>
 
-      <!-- Relax reflective access constraints for tests -->
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
-        </configuration>
-      </plugin>
-
       <!-- Enable Log4j plugin processing -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -128,4 +119,40 @@
     </plugins>
   </build>
 
+  <profiles>
+
+    <!-- Relax reflective access constraints for tests -->
+    <profile>
+
+      <id>reflective-access-fixes</id>
+
+      <!-- CI uses Java 8 for running tests.
+           Though illegal access is disabled by default in Java 16 due to JEP-396.
+           Hence, we assume CI=Java8 and open modules only elsewhere.
+
+           One might think why not activate using `<jdk>[16,)` instead?
+           This doesn't work, since the match is not against "the JDK used by tests".
+           See `java8-tests` profile in `/pom.xml` for details. -->
+      <activation>
+        <property>
+          <name>!env.CI</name>
+        </property>
+      </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+
+    </profile>
+
+  </profiles>
+
 </project>
diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml
index 068fb492ff..885fd510b4 100644
--- a/log4j-osgi-test/pom.xml
+++ b/log4j-osgi-test/pom.xml
@@ -201,11 +201,46 @@
             <!-- Used in `osgi.properties -->
             <felix.cache.rootdir>${project.build.directory}</felix.cache.rootdir>
           </systemPropertyVariables>
-          <!-- Relax reflective access constraints for tests -->
-          <argLine>--add-opens java.base/java.net=ALL-UNNAMED</argLine>
         </configuration>
       </plugin>
 
     </plugins>
   </build>
+
+  <profiles>
+
+    <!-- Relax reflective access constraints for tests -->
+    <profile>
+
+      <id>reflective-access-fixes</id>
+
+      <!-- CI uses Java 8 for running tests.
+           Though illegal access is disabled by default in Java 16 due to JEP-396.
+           Hence, we assume CI=Java8 and open modules only elsewhere.
+
+           One might think why not activate using `<jdk>[16,)` instead?
+           This doesn't work, since the match is not against "the JDK used by tests".
+           See `java8-tests` profile in `/pom.xml` for details. -->
+      <activation>
+        <property>
+          <name>!env.CI</name>
+        </property>
+      </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <argLine>--add-opens java.base/java.net=ALL-UNNAMED</argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+
+    </profile>
+
+  </profiles>
+
 </project>