Skip to content

Commit 7234911

Browse files
authored
[Build] Remove obsolete jdk11 and errorprone-jdk11 maven profiles (#15505)
* [Build] Remove jdk11 profile since build requires Java 17+ * [Build] Add enforcer plugin * Fix issue when running on Java 8 * Remove duplicate maven-enforcer-plugin definition * Upgrade maven-compiler-plugin version * Clean before running shade tests to compile tests with current Java version * Use pulsar.broker.compiler.release property to control the default release setting - it's not possible to clear maven.compiler.release property in a profile and that's why it's better to not use maven.compiler.release property
1 parent 421fa1f commit 7234911

File tree

3 files changed

+47
-102
lines changed

3 files changed

+47
-102
lines changed

build/run_integration_group.sh

+14-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ set -e
2424
set -o pipefail
2525
set -o errexit
2626

27+
JAVA_MAJOR_VERSION="$(java -version 2>&1 |grep " version " | awk -F\" '{ print $2 }' | awk -F. '{ if ($1=="1") { print $2 } else { print $1 } }')"
28+
2729
# lists all active maven modules with given parameters
2830
# parses the modules from the "mvn initialize" output
2931
# returns a CSV value
@@ -66,19 +68,24 @@ mvn_run_integration_test() {
6668
skip_build_deps=1
6769
shift
6870
done
71+
local clean_arg=""
72+
if [[ "$1" == "--clean" ]]; then
73+
clean_arg="clean"
74+
shift
75+
fi
6976
cd "$SCRIPT_DIR"/../tests
7077
modules=$(mvn_list_modules -DskipDocker "$@")
7178
cd ..
7279
set -x
7380
if [ $skip_build_deps -ne 1 ]; then
7481
echo "::group::Build dependencies for $modules"
75-
mvn -B -T 1C -ntp -pl "$modules" -DskipDocker -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true -Dmaven.test.skip=true -Dcheckstyle.skip=true -Drat.skip=true -am install "$@"
82+
mvn -B -T 1C -ntp -pl "$modules" -DskipDocker -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true -Dmaven.test.skip=true -Dcheckstyle.skip=true -Drat.skip=true -am $clean_arg install "$@"
7683
echo "::endgroup::"
7784
fi
7885
if [[ $build_only -ne 1 ]]; then
7986
echo "::group::Run tests for " "$@"
8087
# use "verify" instead of "test"
81-
$RETRY mvn -B -ntp -pl "$modules" -DskipDocker -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true -DredirectTestOutputToFile=false verify "$@"
88+
$RETRY mvn -B -ntp -pl "$modules" -DskipDocker -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true -DredirectTestOutputToFile=false $clean_arg verify "$@"
8289
echo "::endgroup::"
8390
set +x
8491
"$SCRIPT_DIR/pulsar_ci_tool.sh" move_test_reports
@@ -95,7 +102,11 @@ test_group_shade_build() {
95102
}
96103

97104
test_group_shade_run() {
98-
mvn_run_integration_test --skip-build-deps "$@" -DShadeTests -DtestForkCount=1 -DtestReuseFork=false -Dmaven.compiler.source=8 -Dmaven.compiler.target=8
105+
local additional_args
106+
if [[ $JAVA_MAJOR_VERSION -gt 8 && $JAVA_MAJOR_VERSION -lt 17 ]]; then
107+
additional_args="-Dmaven.compiler.source=$JAVA_MAJOR_VERSION -Dmaven.compiler.target=$JAVA_MAJOR_VERSION"
108+
fi
109+
mvn_run_integration_test --skip-build-deps --clean "$@" -Denforcer.skip=true -DShadeTests -DtestForkCount=1 -DtestReuseFork=false $additional_args
99110
}
100111

101112
test_group_backwards_compat() {

buildtools/pom.xml

+5-16
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050
<guava.version>31.0.1-jre</guava.version>
5151
<ant.version>1.10.12</ant.version>
5252
<snakeyaml.version>1.30</snakeyaml.version>
53-
<test.additional.args></test.additional.args>
53+
<!-- required for running tests on JDK11+ -->
54+
<test.additional.args>
55+
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
56+
--add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
57+
</test.additional.args>
5458
</properties>
5559

5660
<dependencyManagement>
@@ -242,19 +246,4 @@
242246
</extension>
243247
</extensions>
244248
</build>
245-
<profiles>
246-
<profile>
247-
<id>jdk11</id>
248-
<activation>
249-
<jdk>[11,)</jdk>
250-
</activation>
251-
<properties>
252-
<!-- required for running tests on JDK11+ -->
253-
<test.additional.args>
254-
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
255-
--add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
256-
</test.additional.args>
257-
</properties>
258-
</profile>
259-
</profiles>
260249
</project>

pom.xml

+28-83
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ flexible messaging model and an intuitive client API.</description>
7979
<properties>
8080
<maven.compiler.source>17</maven.compiler.source>
8181
<maven.compiler.target>17</maven.compiler.target>
82+
<pulsar.broker.compiler.release>${maven.compiler.target}</pulsar.broker.compiler.release>
8283
<pulsar.client.compiler.release>8</pulsar.client.compiler.release>
8384

8485
<!--config keys to configure test selection -->
@@ -90,7 +91,12 @@ flexible messaging model and an intuitive client API.</description>
9091
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9192
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
9293
<redirectTestOutputToFile>true</redirectTestOutputToFile>
93-
<test.additional.args></test.additional.args>
94+
<!-- required for running tests on JDK11+ -->
95+
<test.additional.args>
96+
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
97+
--add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
98+
--add-opens java.base/java.io=ALL-UNNAMED <!--Bookkeeper NativeIO -->
99+
</test.additional.args>
94100
<testReuseFork>true</testReuseFork>
95101
<testForkCount>4</testForkCount>
96102
<testRealAWS>false</testRealAWS>
@@ -238,13 +244,13 @@ flexible messaging model and an intuitive client API.</description>
238244
<exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
239245
<license-maven-plugin.version>4.0.rc2</license-maven-plugin.version>
240246
<directory-maven-plugin.version>1.0</directory-maven-plugin.version>
241-
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
247+
<maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
242248
<!-- surefire.version is defined in apache parent pom -->
243249
<!-- it is used for surefire, failsafe and surefire-report plugins -->
244250
<!-- do not upgrade surefire.version to 3.0.0-M5 since it runs slowly and breaks tests. -->
245251
<surefire.version>3.0.0-M3</surefire.version>
246252
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
247-
<maven-compiler-plugin.version>3.9.0</maven-compiler-plugin.version>
253+
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
248254
<maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
249255
<maven-modernizer-plugin.version>2.3.0</maven-modernizer-plugin.version>
250256
<maven-shade-plugin>3.3.0</maven-shade-plugin>
@@ -1703,10 +1709,11 @@ flexible messaging model and an intuitive client API.</description>
17031709
<configuration>
17041710
<rules>
17051711
<requireJavaVersion>
1706-
<version>[1.8.0,)</version>
1712+
<version>17</version>
1713+
<message>Java 17+ is required to build Pulsar.</message>
17071714
</requireJavaVersion>
17081715
<requireMavenVersion>
1709-
<version>[3.3.9,)</version>
1716+
<version>3.6.1</version>
17101717
</requireMavenVersion>
17111718
</rules>
17121719
</configuration>
@@ -1749,6 +1756,9 @@ flexible messaging model and an intuitive client API.</description>
17491756
<groupId>org.apache.maven.plugins</groupId>
17501757
<artifactId>maven-compiler-plugin</artifactId>
17511758
<version>${maven-compiler-plugin.version}</version>
1759+
<configuration>
1760+
<release>${pulsar.broker.compiler.release}</release>
1761+
</configuration>
17521762
</plugin>
17531763
<plugin>
17541764
<groupId>org.gaul</groupId>
@@ -1878,35 +1888,18 @@ flexible messaging model and an intuitive client API.</description>
18781888

18791889
<profiles>
18801890
<profile>
1881-
<id>jdk11</id>
1891+
<!-- used for running integration tests on Java 8 -->
1892+
<id>integration-test-java8</id>
18821893
<activation>
1883-
<jdk>[11,)</jdk>
1894+
<jdk>1.8</jdk>
18841895
</activation>
18851896
<properties>
1886-
<!-- prevents silent NoSuchMethodErrors that happen at runtime on Java 8 -->
1887-
<!-- see https://github.com/apache/pulsar/issues/8445 -->
1888-
<maven.compiler.release>${maven.compiler.target}</maven.compiler.release>
1889-
<!-- required for running tests on JDK11+ -->
1890-
<test.additional.args>
1891-
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
1892-
--add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
1893-
--add-opens java.base/java.io=ALL-UNNAMED <!--Bookkeeper NativeIO -->
1894-
</test.additional.args>
1897+
<test.additional.args/>
1898+
<maven.compiler.source>8</maven.compiler.source>
1899+
<maven.compiler.target>8</maven.compiler.target>
1900+
<pulsar.broker.compiler.release></pulsar.broker.compiler.release>
1901+
<pulsar.client.compiler.release></pulsar.client.compiler.release>
18951902
</properties>
1896-
<build>
1897-
<pluginManagement>
1898-
<plugins>
1899-
<plugin>
1900-
<groupId>org.apache.maven.plugins</groupId>
1901-
<artifactId>maven-compiler-plugin</artifactId>
1902-
<configuration>
1903-
<!-- for some reason, setting maven.compiler.release property alone doesn't work -->
1904-
<release>${maven.compiler.release}</release>
1905-
</configuration>
1906-
</plugin>
1907-
</plugins>
1908-
</pluginManagement>
1909-
</build>
19101903
</profile>
19111904
<profile>
19121905
<id>coverage</id>
@@ -2169,21 +2162,18 @@ flexible messaging model and an intuitive client API.</description>
21692162
<!--
21702163
Configure Google Error Prone static code analyser, http://errorprone.info
21712164

2172-
consists of 3 maven profiles: errorprone, errorprone-jdk8 and errorprone-jdk11
2173-
21742165
usage:
2175-
activate profiles "errorprone" and either "errorprone-jdk8" or "errorprone-jdk11"
2176-
depending on the JVM version
2166+
activate profile "errorprone"
21772167

21782168
It is required to add "lombok.addJavaxGeneratedAnnotation = true" to lombok.config
21792169
temporarily before running the analysis.
21802170

21812171
usage example:
21822172
echo lombok.addJavaxGeneratedAnnotation=true >> lombok.config
2183-
mvn -Perrorprone,errorprone-jdk11,main compile
2173+
mvn -Perrorprone,main compile
21842174

21852175
Revisiting warnings and errors is possible in IntelliJ after activating
2186-
errorprone, errorprone-jdk11 and main in "Maven->Profiles" and choosing
2176+
errorprone and main in "Maven->Profiles" and choosing
21872177
"Build->Rebuild Project"
21882178
Compiling all Pulsar projects in IntelliJ requires some manual tweaks to get the
21892179
shaded projects to pass compilation. In some cases, it's better to mark the project
@@ -2208,7 +2198,7 @@ flexible messaging model and an intuitive client API.</description>
22082198
<arg>-Xlint:-options</arg>
22092199
<!-- configure Error Prone . Disable some checks that crash the compiler or are annoying -->
22102200
<!-- the following argument must be kept on one line when building with JDK8 -->
2211-
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-sources/.* -XepDisableWarningsInGeneratedCode -Xep:UnusedVariable:OFF -Xep:FallThrough:OFF -Xep:OverrideThrowableToString:OFF -Xep:UnusedMethod:OFF -Xep:StringSplitter:OFF -Xep:CanonicalDuration:OFF ${errorprone.arguments.jdk11}</arg>
2201+
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-sources/.* -XepDisableWarningsInGeneratedCode -Xep:UnusedVariable:OFF -Xep:FallThrough:OFF -Xep:OverrideThrowableToString:OFF -Xep:UnusedMethod:OFF -Xep:StringSplitter:OFF -Xep:CanonicalDuration:OFF -Xep:Slf4jDoNotLogMessageOfExceptionExplicitly:WARN -Xep:Slf4jSignOnlyFormat:WARN -Xep:Slf4jFormatShouldBeConst:WARN -Xep:Slf4jLoggerShouldBePrivate:WARN -Xep:Slf4jLoggerShouldBeNonStatic:OFF</arg>
22122202
</compilerArgs>
22132203
<annotationProcessorPaths combine.children="append">
22142204
<path>
@@ -2221,53 +2211,8 @@ flexible messaging model and an intuitive client API.</description>
22212211
<artifactId>mockito-errorprone</artifactId>
22222212
<version>${mockito.version}</version>
22232213
</path>
2224-
</annotationProcessorPaths>
2225-
</configuration>
2226-
</plugin>
2227-
</plugins>
2228-
</build>
2229-
</profile>
2230-
<!-- running errorprone on JDK 8 requires special javac configuration -->
2231-
<profile>
2232-
<id>errorprone-jdk8</id>
2233-
<build>
2234-
<plugins>
2235-
<plugin>
2236-
<groupId>org.apache.maven.plugins</groupId>
2237-
<artifactId>maven-compiler-plugin</artifactId>
2238-
<configuration>
2239-
<compilerArgs combine.children="append">
2240-
<arg>
2241-
-J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${errorprone.javac.version}/javac-${errorprone.javac.version}.jar</arg>
2242-
</compilerArgs>
2243-
<annotationProcessorPaths combine.children="append">
2244-
<path>
2245-
<groupId>com.google.errorprone</groupId>
2246-
<artifactId>javac</artifactId>
2247-
<version>${errorprone.javac.version}</version>
2248-
</path>
2249-
</annotationProcessorPaths>
2250-
</configuration>
2251-
</plugin>
2252-
</plugins>
2253-
</build>
2254-
</profile>
2255-
<profile>
2256-
<id>errorprone-jdk11</id>
2257-
<properties>
2258-
<!-- pass the additional properties to -Xplugin:ErrorProne argument defined in errorprone profile -->
2259-
<!-- change configuration of slf4j checks to be more permissive -->
2260-
<errorprone.arguments.jdk11>-Xep:Slf4jDoNotLogMessageOfExceptionExplicitly:WARN -Xep:Slf4jSignOnlyFormat:WARN -Xep:Slf4jFormatShouldBeConst:WARN -Xep:Slf4jLoggerShouldBePrivate:WARN -Xep:Slf4jLoggerShouldBeNonStatic:OFF</errorprone.arguments.jdk11>
2261-
</properties>
2262-
<build>
2263-
<plugins>
2264-
<plugin>
2265-
<groupId>org.apache.maven.plugins</groupId>
2266-
<artifactId>maven-compiler-plugin</artifactId>
2267-
<configuration>
2268-
<annotationProcessorPaths combine.children="append">
22692214
<!-- add https://github.com/KengoTODA/errorprone-slf4j Error Prone plugin -->
2270-
<!-- detects slf4j misusage. Doesn't run on Java 8, so this is why it's in the errorprone-jdk11 profile -->
2215+
<!-- detects slf4j misusage. -->
22712216
<path>
22722217
<groupId>jp.skypencil.errorprone.slf4j</groupId>
22732218
<artifactId>errorprone-slf4j</artifactId>

0 commit comments

Comments
 (0)