Skip to content

Commit b7189ae

Browse files
ppkarwaszvy
andcommitted
Switch build to JDK 17
Co-authored-by: Volkan Yazıcı <volkan@yazi.ci>
1 parent c90892c commit b7189ae

File tree

18 files changed

+197
-488
lines changed

18 files changed

+197
-488
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,18 @@ jobs:
4949
with:
5050
fetch-depth: 32
5151

52-
# JDK 8 and 11 is needed for the build.
52+
# JDK 17 is used for the build.
53+
# JDK 8 is used for the tests.
5354
# Search `maven-toolchains-plugin` usages for details.
5455
- name: Setup JDK
5556
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
5657
with:
5758
distribution: temurin
59+
# The last provided Java version will be used and available globally.
60+
# Other Java versions can be accessed through environment variables: `JAVA_HOME_<majorVersion>_<architecture>`
5861
java-version: |
5962
8
60-
11
63+
17
6164
architecture: x64
6265
cache: maven
6366

@@ -68,9 +71,10 @@ jobs:
6871
- name: Build
6972
timeout-minutes: 60
7073
shell: bash
71-
env:
72-
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
73-
run: ./mvnw clean install
74+
run: |
75+
./mvnw \
76+
-Pjava8-tests \
77+
clean install
7478
7579
- name: Upload Surefire Reports
7680
if: failure()
@@ -85,8 +89,6 @@ jobs:
8589
id: report-reproducible
8690
timeout-minutes: 10
8791
shell: bash
88-
env:
89-
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
9092
run: |
9193
./mvnw \
9294
-DskipTests=true \
@@ -105,8 +107,6 @@ jobs:
105107
- name: Build site
106108
timeout-minutes: 10
107109
shell: bash
108-
env:
109-
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
110110
run: ./mvnw site
111111

112112
merge:
@@ -138,15 +138,18 @@ jobs:
138138
with:
139139
fetch-depth: 32
140140

141-
# JDK 8 and 11 are needed for the build.
141+
# JDK 17 is used for the build.
142+
# JDK 8 is used for the tests.
142143
# Search `maven-toolchains-plugin` usages for details.
143144
- name: Setup JDK
144145
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
145146
with:
146147
distribution: temurin
148+
# The last provided Java version will be used and available globally.
149+
# Other Java versions can be accessed through environment variables: `JAVA_HOME_<majorVersion>_<architecture>`
147150
java-version: |
148151
8
149-
11
152+
17
150153
architecture: x64
151154
cache: maven
152155

@@ -173,6 +176,5 @@ jobs:
173176
-DskipTests=true \
174177
package install:install deploy:deploy
175178
env:
176-
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
177179
NEXUS_USER: ${{ secrets.NEXUS_USER }}
178180
NEXUS_PW: ${{ secrets.NEXUS_PW }}

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,17 @@ jobs:
6262
# Prefix the list here with "+" to use these queries and those in the config file.
6363
# queries: ./path/to/local/query, your-org/your-repo/queries@main
6464

65-
# JDK 8 and 11 is needed for the build.
66-
# Search `maven-toolchains-plugin` usages for details.
65+
# JDK 17 is used for the build.
6766
- name: Setup JDK
6867
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
6968
with:
7069
distribution: temurin
71-
java-version: |
72-
8
73-
11
70+
java-version: 17
7471
cache: maven
7572

7673
- name: Build with Maven
7774
timeout-minutes: 60
7875
shell: bash
79-
env:
80-
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
8176
run: |
8277
./mvnw \
8378
--show-version --batch-mode --errors --no-transfer-progress \

.github/workflows/log4j-kafka-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ jobs:
5858
--show-version --batch-mode --errors --no-transfer-progress --fail-at-end \
5959
-Dkafka.version=${{ matrix.version }} \
6060
-pl log4j-core-test -Dtest=Kafka*Test \
61+
-P java8-tests \
6162
test

log4j-api-java9/pom.xml

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<docLabel>API Documentation</docLabel>
3232
<projectDir>/api</projectDir>
3333
<maven.deploy.skip>true</maven.deploy.skip>
34+
<maven.compiler.release>9</maven.compiler.release>
3435
</properties>
3536
<dependencies>
3637
<dependency>
@@ -65,6 +66,7 @@
6566
</execution>
6667
</executions>
6768
</plugin>
69+
6870
<plugin>
6971
<groupId>org.apache.maven.plugins</groupId>
7072
<artifactId>maven-compiler-plugin</artifactId>
@@ -77,62 +79,38 @@
7779
<goals>
7880
<goal>compile</goal>
7981
</goals>
80-
<phase>compile</phase>
81-
<configuration>
82-
<jdkToolchain>
83-
<version>[9, )</version>
84-
</jdkToolchain>
85-
<release>9</release>
86-
</configuration>
8782
</execution>
88-
<!-- We explicitly compile tests using Java 8 to work around SUREFIRE-2073 -->
8983
<execution>
9084
<id>default-test-compile</id>
9185
<goals>
9286
<goal>testCompile</goal>
9387
</goals>
9488
<phase>test-compile</phase>
9589
</execution>
96-
<!-- Of course the 'module-info.java' needs Java 9 -->
97-
<execution>
98-
<id>test-compile-module</id>
99-
<goals>
100-
<goal>testCompile</goal>
101-
</goals>
102-
<phase>test-compile</phase>
103-
<configuration>
104-
<jdkToolchain>
105-
<version>[9, )</version>
106-
</jdkToolchain>
107-
<release>9</release>
108-
<compileSourceRoots>
109-
<compileSourceRoot>${project.basedir}/src/test/java9</compileSourceRoot>
110-
</compileSourceRoots>
111-
</configuration>
112-
</execution>
11390
</executions>
11491
</plugin>
92+
11593
<plugin>
11694
<groupId>org.apache.maven.plugins</groupId>
11795
<artifactId>maven-surefire-plugin</artifactId>
118-
<configuration>
119-
<systemPropertyVariables>
120-
<java.awt.headless>true</java.awt.headless>
121-
</systemPropertyVariables>
122-
<jdkToolchain>
123-
<version>[9, )</version>
124-
</jdkToolchain>
125-
</configuration>
12696
<executions>
12797
<execution>
12898
<id>test</id>
12999
<goals>
130100
<goal>test</goal>
131101
</goals>
132-
<phase>test</phase>
133102
</execution>
134103
</executions>
135104
</plugin>
136105
</plugins>
137106
</build>
107+
108+
<profiles>
109+
<profile>
110+
<id>java8-tests</id>
111+
<properties>
112+
<surefire.jdkToolchain>[9, )</surefire.jdkToolchain>
113+
</properties>
114+
</profile>
115+
</profiles>
138116
</project>

log4j-api-java9/src/test/java9/org/apache/logging/log4j/util/java9/ModuleUtil.java renamed to log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ModuleUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* Licensed to the Apache Software Foundation (ASF) under one or more
3-
* contributor license agreements. See the NOTICE file distributed with
3+
* contributor license agreements. See the NOTICE file distributed with
44
* this work for additional information regarding copyright ownership.
5-
* The ASF licenses this file to You under the Apache license, Version 2.0
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
66
* (the "License"); you may not use this file except in compliance with
7-
* the License. You may obtain a copy of the License at
7+
* the License. You may obtain a copy of the License at
88
*
99
* http://www.apache.org/licenses/LICENSE-2.0
1010
*
1111
* Unless required by applicable law or agreed to in writing, software
1212
* distributed under the License is distributed on an "AS IS" BASIS,
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the license for the specific language governing permissions and
15-
* limitations under the license.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1616
*/
1717
package org.apache.logging.log4j.util.java9;
1818

log4j-api-test/pom.xml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
</dependencies>
107107
<build>
108108
<plugins>
109+
109110
<plugin>
110111
<groupId>org.apache.felix</groupId>
111112
<artifactId>maven-bundle-plugin</artifactId>
@@ -117,24 +118,7 @@
117118
</instructions>
118119
</configuration>
119120
</plugin>
120-
<plugin>
121-
<groupId>org.apache.maven.plugins</groupId>
122-
<artifactId>maven-compiler-plugin</artifactId>
123-
<executions>
124-
<execution>
125-
<id>default-compile</id>
126-
<!-- recompile everything for target VM except the module-info.java -->
127-
<configuration>
128-
<source>1.8</source>
129-
<target>1.8</target>
130-
</configuration>
131-
</execution>
132-
</executions>
133-
</plugin>
134-
<plugin>
135-
<groupId>org.apache.maven.plugins</groupId>
136-
<artifactId>maven-deploy-plugin</artifactId>
137-
</plugin>
121+
138122
<plugin>
139123
<groupId>org.apache.maven.plugins</groupId>
140124
<artifactId>maven-jar-plugin</artifactId>
@@ -164,6 +148,7 @@
164148
</execution>
165149
</executions>
166150
</plugin>
151+
167152
<plugin>
168153
<groupId>org.apache.maven.plugins</groupId>
169154
<artifactId>maven-surefire-plugin</artifactId>
@@ -172,6 +157,7 @@
172157
<excludedGroups>performance,smoke</excludedGroups>
173158
</configuration>
174159
</plugin>
160+
175161
</plugins>
176162
</build>
177163
</project>

log4j-api-test/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,29 @@
1919
import java.util.Deque;
2020
import java.util.Stack;
2121

22-
import org.junit.Test;
23-
import org.junit.jupiter.api.Assertions;
24-
import org.junit.runner.RunWith;
25-
import org.junit.runners.BlockJUnit4ClassRunner;
26-
import org.junit.runners.ParentRunner;
27-
import sun.reflect.Reflection;
22+
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.condition.EnabledOnJre;
24+
import org.junit.jupiter.api.condition.JRE;
25+
import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
26+
import org.junit.platform.engine.support.hierarchical.ThrowableCollector;
2827

29-
import static org.junit.Assert.assertEquals;
30-
import static org.junit.Assert.assertNotNull;
31-
import static org.junit.Assert.assertSame;
28+
import static org.junit.jupiter.api.Assertions.assertEquals;
29+
import static org.junit.jupiter.api.Assertions.assertNotNull;
30+
import static org.junit.jupiter.api.Assertions.assertSame;
3231

3332
/**
34-
* Tests {@link StackLocatorUtilTest}.
33+
* Tests {@link StackLocatorUtil}.
3534
*/
36-
@RunWith(BlockJUnit4ClassRunner.class)
3735
public class StackLocatorUtilTest {
3836

3937
@Test
38+
@EnabledOnJre(JRE.JAVA_8)
4039
public void testStackTraceEquivalence() throws Exception {
41-
for (int i = 1; i < 15; i++) {
42-
final Class<?> expected = Reflection.getCallerClass(i + StackLocator.JDK_7U25_OFFSET);
40+
// Frame 8 is a hidden frame and does not show in the stacktrace
41+
for (int i = 1; i < 8; i++) {
42+
final Class<?> expected = (Class<?>) Class.forName("sun.reflect.Reflection")
43+
.getMethod("getCallerClass", int.class)
44+
.invoke(null, i + StackLocator.JDK_7U25_OFFSET);
4345
final Class<?> actual = StackLocatorUtil.getCallerClass(i);
4446
final Class<?> fallbackActual = Class.forName(
4547
StackLocatorUtil.getStackTraceElement(i).getClassName());
@@ -88,22 +90,23 @@ public void testTopElementInStackTrace() {
8890
final Deque<Class<?>> classes = stackLocator.getCurrentStackTrace();
8991
//Removing private class in "PrivateSecurityManagerStackTraceUtil"
9092
classes.removeFirst();
91-
Assertions.assertSame(PrivateSecurityManagerStackTraceUtil.class, classes.getFirst());
93+
assertSame(PrivateSecurityManagerStackTraceUtil.class, classes.getFirst());
9294
}
9395

9496
@Test
9597
public void testGetCallerClassViaName() throws Exception {
96-
final Class<?> expected = BlockJUnit4ClassRunner.class;
97-
final Class<?> actual = StackLocatorUtil.getCallerClass("org.junit.runners.ParentRunner");
98+
if (true) new RuntimeException().printStackTrace();
99+
final Class<?> expected = TestMethodTestDescriptor.class;
100+
final Class<?> actual = StackLocatorUtil.getCallerClass("org.junit.platform.engine.support.hierarchical.ThrowableCollector");
98101
// if this test fails in the future, it's probably because of a JUnit upgrade; check the new stack trace and
99102
// update this test accordingly
100103
assertSame(expected, actual);
101104
}
102105

103106
@Test
104107
public void testGetCallerClassViaAnchorClass() throws Exception {
105-
final Class<?> expected = BlockJUnit4ClassRunner.class;
106-
final Class<?> actual = StackLocatorUtil.getCallerClass(ParentRunner.class);
108+
final Class<?> expected = TestMethodTestDescriptor.class;
109+
final Class<?> actual = StackLocatorUtil.getCallerClass(ThrowableCollector.class);
107110
// if this test fails in the future, it's probably because of a JUnit upgrade; check the new stack trace and
108111
// update this test accordingly
109112
assertSame(expected, actual);
@@ -113,8 +116,8 @@ public void testGetCallerClassViaAnchorClass() throws Exception {
113116
public void testLocateClass() {
114117
final ClassLocator locator = new ClassLocator();
115118
final Class<?> clazz = locator.locateClass();
116-
assertNotNull("Could not locate class", clazz);
117-
assertEquals("Incorrect class", this.getClass(), clazz);
119+
assertNotNull(clazz, "Could note locate class");
120+
assertEquals(this.getClass(), clazz, "Incorrect class");
118121
}
119122

120123
}

0 commit comments

Comments
 (0)