Skip to content

Commit a792145

Browse files
committed
fix(build): Move --add-opens option to Maven profile
The `--add-opens` JVM option is now included in a dedicated Maven profile to avoid applying it during CI builds on JRE 8, where it is unsupported and unnecessary.
1 parent 05d97d2 commit a792145

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

log4j-to-slf4j/pom.xml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,44 @@
154154
</executions>
155155
</plugin>
156156

157-
<!-- Illegal access is disabled by default in Java 16 due to JEP-396.
158-
We are relaxing it for tests. -->
159-
<plugin>
160-
<groupId>org.apache.maven.plugins</groupId>
161-
<artifactId>maven-surefire-plugin</artifactId>
162-
<configuration>
163-
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
164-
</configuration>
165-
</plugin>
166-
167157
</plugins>
168158
</build>
159+
160+
<profiles>
161+
162+
<!-- Fixes incompatible with Java 8 -->
163+
<profile>
164+
165+
<id>java8-incompat-fixes</id>
166+
167+
<!-- CI uses Java 8 for running tests.
168+
Hence, we assume CI=Java8 and apply our changes elsewhere.
169+
170+
One might think why not activate using `<jdk>[16,)` instead?
171+
This doesn't work, since the match is not against "the JDK running tests", but "the JDK running Maven".
172+
These two JDKs can differ due to Maven Toolchains.
173+
See `java8-tests` profile in `/pom.xml` for details. -->
174+
<activation>
175+
<property>
176+
<name>!env.CI</name>
177+
</property>
178+
</activation>
179+
180+
<!-- Illegal access is disabled by default in Java 16 due to JEP-396.
181+
We are relaxing it for tests. -->
182+
<build>
183+
<plugins>
184+
<plugin>
185+
<groupId>org.apache.maven.plugins</groupId>
186+
<artifactId>maven-surefire-plugin</artifactId>
187+
<configuration>
188+
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
189+
</configuration>
190+
</plugin>
191+
</plugins>
192+
</build>
193+
194+
</profile>
195+
196+
</profiles>
169197
</project>

0 commit comments

Comments
 (0)