Skip to content

Commit f4e9392

Browse files
Add JDK 17, 21, 25 to PR CI Matrix (#4305)
* Update PR CI to run on JDK 8, 17, 21, and 25 Modified .github/workflows/pr.yml to use a matrix strategy for testing across multiple JDK versions. Ensured that artifact generation, static analysis, and reporting steps are executed only for the default JDK 8 build. Retained legacy JDK 8 setup (with JavaFX) while using setup-java@v4 for newer JDKs. * Fix Maven compilation for JDK 9+ by overriding Java 1.5 target Modified maven/core/pom.xml and vm/JavaAPI/pom.xml to use Maven properties for compiler source/target settings. Added a 'modern-jdk' Maven profile activated on JDK 9+ to set compiler source/target to 1.8. This resolves 'Source option 5 is no longer supported' errors when building with newer JDKs in the CI matrix. * Fix JDK 17+ build failure by restricting tools.jar dependency Modified maven/parparvm/pom.xml to move the system dependency on tools.jar into a Maven profile active only for JDKs < 9. This prevents the 'Could not find artifact com.sun:tools:jar:1.5.0' error on newer JDKs (like 17+) where tools.jar has been removed. * Fix ParparVM JavaAPI compilation for JDK 9+ Modified maven/parparvm/pom.xml to use Maven properties for the javac task source/target versions. Added a 'modern-jdk' Maven profile activated on JDK 9+ to override these properties to 1.8. This resolves the 'Source option 5 is no longer supported' error in the ParparVM build when running on newer JDKs. * Fix Ant build failures on JDK 9+ by injecting javac properties Modified .github/workflows/pr.yml to pass -Djavac.source=1.8 -Djavac.target=1.8 to Ant commands when running on JDK 9+ (i.e., non-JDK 8 builds). This overrides the project.properties setting (1.6) which caused 'Source option 6 is no longer supported' errors on modern JDKs, while preserving the legacy configuration for the default JDK 8 pipeline. * Fix Ant test-javase failure on newer JDKs Moved the 'Build CLDC11 JAR' step before 'Build with Ant' (test-javase) in pr.yml. This ensures the CLDC11 jar is pre-built with the correct compiler options (1.8) on modern JDKs, preventing the 'CodenameOneCLI' test runner from failing when attempting to rebuild it with default (1.6) options. * Skip SpotBugs on non-JDK 8 builds Modified .github/workflows/pr.yml to append -Dspotbugs.skip=true to the Maven command for all JDK versions except 8. This prevents build failures on newer JDKs (like JDK 25) caused by SpotBugs incompatibility with modern class file versions, while ensuring static analysis remains active for the default pipeline. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent d33315b commit f4e9392

File tree

4 files changed

+137
-31
lines changed

4 files changed

+137
-31
lines changed

.github/workflows/pr.yml

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,28 @@ permissions:
3434
issues: write
3535

3636
jobs:
37-
build-linux-jdk8-fx:
37+
build-test:
3838

3939
runs-on: ubuntu-latest
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
java-version: [8, 17, 21, 25]
4044

4145
steps:
4246
- uses: actions/checkout@v1
4347
- name: Set up JDK 8
48+
if: matrix.java-version == 8
4449
uses: actions/setup-java@v1
4550
with:
4651
java-version: 1.8
4752
java-package: jdk+fx
53+
- name: Set up JDK
54+
if: matrix.java-version != 8
55+
uses: actions/setup-java@v4
56+
with:
57+
distribution: 'zulu'
58+
java-version: ${{ matrix.java-version }}
4859
- name: Cache Maven dependencies
4960
uses: actions/cache@v4
5061
with:
@@ -54,8 +65,12 @@ jobs:
5465
${{ runner.os }}-m2
5566
- name: Run Unit Tests
5667
run: |
68+
MVN_ARGS=""
69+
if [ "${{ matrix.java-version }}" != "8" ]; then
70+
MVN_ARGS="-Dspotbugs.skip=true"
71+
fi
5772
cd maven
58-
mvn clean verify -DunitTests=true -pl core-unittests -am -Dmaven.javadoc.skip=true -Plocal-dev-javase
73+
mvn clean verify -DunitTests=true -pl core-unittests -am -Dmaven.javadoc.skip=true -Plocal-dev-javase $MVN_ARGS
5974
cd ..
6075
- name: Prepare Codename One binaries for Maven plugin tests
6176
run: |
@@ -73,7 +88,7 @@ jobs:
7388
-Dcn1.binaries="${CN1_BINARIES}" \
7489
-pl codenameone-maven-plugin -am -Plocal-dev-javase test
7590
- name: Generate static analysis HTML summaries
76-
if: ${{ always() }}
91+
if: ${{ always() && matrix.java-version == 8 }}
7792
env:
7893
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target
7994
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
@@ -82,7 +97,7 @@ jobs:
8297
QUALITY_REPORT_GENERATE_HTML_ONLY: "1"
8398
run: python3 .github/scripts/generate-quality-report.py
8499
- name: Collect quality artifacts
85-
if: ${{ always() }}
100+
if: ${{ always() && matrix.java-version == 8 }}
86101
run: |
87102
set -euo pipefail
88103
mkdir -p quality-artifacts/static-analysis
@@ -110,14 +125,14 @@ jobs:
110125
echo "No quality artifacts were generated." > quality-artifacts/README.txt
111126
fi
112127
- name: Upload quality artifacts
113-
if: ${{ always() }}
128+
if: ${{ always() && matrix.java-version == 8 }}
114129
id: upload-quality-artifacts
115130
uses: actions/upload-artifact@v4
116131
with:
117132
name: quality-artifacts
118133
path: quality-artifacts
119134
- name: Publish quality report previews
120-
if: ${{ always() && github.server_url == 'https://github.com' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
135+
if: ${{ always() && matrix.java-version == 8 && github.server_url == 'https://github.com' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
121136
id: publish-quality-previews
122137
env:
123138
GITHUB_TOKEN: ${{ github.token }}
@@ -183,7 +198,7 @@ jobs:
183198
echo "jacoco_url=${preview_base}/coverage/index.html" >> "$GITHUB_OUTPUT"
184199
fi
185200
- name: Generate quality report summary
186-
if: ${{ always() }}
201+
if: ${{ always() && matrix.java-version == 8 }}
187202
env:
188203
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target
189204
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
@@ -199,13 +214,13 @@ jobs:
199214
JACOCO_HTML_URL: ${{ steps.publish-quality-previews.outputs.jacoco_url }}
200215
run: python3 .github/scripts/generate-quality-report.py
201216
- name: Upload quality report summary
202-
if: ${{ always() }}
217+
if: ${{ always() && matrix.java-version == 8 }}
203218
uses: actions/upload-artifact@v4
204219
with:
205220
name: quality-report
206221
path: quality-report.md
207222
- name: Publish quality report comment
208-
if: ${{ github.event_name == 'pull_request' }}
223+
if: ${{ github.event_name == 'pull_request' && matrix.java-version == 8 }}
209224
uses: actions/github-script@v7
210225
with:
211226
script: |
@@ -217,15 +232,27 @@ jobs:
217232
wget https://github.com/codenameone/cn1-binaries/archive/refs/heads/master.zip
218233
unzip master.zip -d ..
219234
mv ../cn1-binaries-master ../cn1-binaries
220-
- name: Build with Ant
221-
run: xvfb-run ant test-javase
222235
- name: Build CLDC11 JAR
223-
run: ant -noinput -buildfile Ports/CLDC11/build.xml jar
236+
run: |
237+
ANT_OPTS_ARGS=""
238+
if [ "${{ matrix.java-version }}" != "8" ]; then
239+
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
240+
fi
241+
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/CLDC11/build.xml jar
242+
- name: Build with Ant
243+
run: |
244+
ANT_OPTS_ARGS=""
245+
if [ "${{ matrix.java-version }}" != "8" ]; then
246+
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
247+
fi
248+
xvfb-run ant $ANT_OPTS_ARGS test-javase
224249
225250
- name: Build Release
251+
if: matrix.java-version == 8
226252
run: ant -noinput -buildfile CodenameOne/build.xml weeklyLibUpdate
227253

228254
- name: Build JavaDocs
255+
if: matrix.java-version == 8
229256
run: |
230257
cd CodenameOne
231258
mkdir -p build
@@ -240,12 +267,18 @@ jobs:
240267
cd ..
241268
242269
- name: Build iOS Port
243-
run: ant -noinput -buildfile Ports/iOSPort/build.xml jar
270+
run: |
271+
ANT_OPTS_ARGS=""
272+
if [ "${{ matrix.java-version }}" != "8" ]; then
273+
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
274+
fi
275+
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/iOSPort/build.xml jar
244276
245277
- name: Build iOS VM API
246278
run: mvn -f vm/JavaAPI/pom.xml package
247279

248280
- name: Upload a Build Artifact
281+
if: matrix.java-version == 8
249282
uses: actions/upload-artifact@v4
250283
with:
251284
name: JavaAPI.jar
@@ -255,27 +288,41 @@ jobs:
255288
run: mvn -f vm/ByteCodeTranslator/pom.xml package
256289

257290
- name: Build CLDC 11 VM
258-
run: ant -noinput -buildfile Ports/CLDC11/build.xml jar
291+
run: |
292+
ANT_OPTS_ARGS=""
293+
if [ "${{ matrix.java-version }}" != "8" ]; then
294+
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
295+
fi
296+
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/CLDC11/build.xml jar
259297
260298
- name: Upload a Build Artifact
299+
if: matrix.java-version == 8
261300
uses: actions/upload-artifact@v4
262301
with:
263302
name: ByteCodeTranslator.jar
264303
path: vm/ByteCodeTranslator/target/ByteCodeTranslator-1.0-SNAPSHOT.jar
265304

266305
- name: Upload a Build Artifact
306+
if: matrix.java-version == 8
267307
uses: actions/upload-artifact@v4
268308
with:
269309
name: CLDC11.jar
270310
path: Ports/CLDC11/dist/CLDC11.jar
271311

272312
- name: Build Android Port
273-
run: ant -noinput -buildfile Ports/Android/build.xml jar
313+
run: |
314+
ANT_OPTS_ARGS=""
315+
if [ "${{ matrix.java-version }}" != "8" ]; then
316+
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
317+
fi
318+
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/Android/build.xml jar
274319
275320
- name: Packaging Everything
321+
if: matrix.java-version == 8
276322
run: zip -j result.zip CodenameOne/javadocs.zip CodenameOne/dist/CodenameOne.jar CodenameOne/updatedLibs.zip Ports/JavaSE/dist/JavaSE.jar build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip
277323

278324
- name: Copying Files to Server
325+
if: matrix.java-version == 8
279326
uses: marcodallasanta/[email protected]
280327
with:
281328
host: ${{ secrets.WP_HOST }}
@@ -284,6 +331,7 @@ jobs:
284331
local: result.zip
285332

286333
- name: Upload a Build Artifact
334+
if: matrix.java-version == 8
287335
uses: actions/upload-artifact@v4
288336
with:
289337
name: JavaSE.jar

maven/core/pom.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,25 @@
4444
<artifactId>maven-compiler-plugin</artifactId>
4545

4646
<configuration>
47-
<source>1.5</source>
48-
<target>1.5</target>
47+
<source>${maven.compiler.source}</source>
48+
<target>${maven.compiler.target}</target>
4949
</configuration>
5050
</plugin>
5151
</plugins>
5252

5353
</build>
54+
<profiles>
55+
<profile>
56+
<id>modern-jdk</id>
57+
<activation>
58+
<jdk>[9,)</jdk>
59+
</activation>
60+
<properties>
61+
<maven.compiler.source>1.8</maven.compiler.source>
62+
<maven.compiler.target>1.8</maven.compiler.target>
63+
</properties>
64+
</profile>
65+
</profiles>
5466

5567

5668
</project>

maven/parparvm/pom.xml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<src.dir>../../vm/ByteCodeTranslator/src</src.dir>
4444

4545
<codename1.javaapi.src.dir>../../vm/JavaAPI/src</codename1.javaapi.src.dir>
46+
<javaapi.compiler.source>1.5</javaapi.compiler.source>
47+
<javaapi.compiler.target>1.5</javaapi.compiler.target>
4648

4749
</properties>
4850

@@ -85,15 +87,6 @@
8587
<plugin>
8688
<groupId>org.apache.maven.plugins</groupId>
8789
<artifactId>maven-antrun-plugin</artifactId>
88-
<dependencies>
89-
<dependency>
90-
<groupId>com.sun</groupId>
91-
<artifactId>tools</artifactId>
92-
<version>1.5.0</version>
93-
<scope>system</scope>
94-
<systemPath>${java.home}/../lib/tools.jar</systemPath>
95-
</dependency>
96-
</dependencies>
9790
<executions>
9891
<execution>
9992
<id>compile-java-api</id>
@@ -105,8 +98,8 @@
10598
<target>
10699
<mkdir dir="${project.build.directory}/api-classes"/>
107100
<javac srcdir="${codename1.javaapi.src.dir}"
108-
source="1.5"
109-
target="1.5"
101+
source="${javaapi.compiler.source}"
102+
target="${javaapi.compiler.target}"
110103
destdir="${project.build.directory}/api-classes"
111104
failonerror="true"
112105
/>
@@ -159,6 +152,41 @@
159152
</plugin>
160153
</plugins>
161154
</build>
162-
155+
156+
<profiles>
157+
<profile>
158+
<id>legacy-jdk-tools</id>
159+
<activation>
160+
<jdk>(,9)</jdk>
161+
</activation>
162+
<build>
163+
<plugins>
164+
<plugin>
165+
<groupId>org.apache.maven.plugins</groupId>
166+
<artifactId>maven-antrun-plugin</artifactId>
167+
<dependencies>
168+
<dependency>
169+
<groupId>com.sun</groupId>
170+
<artifactId>tools</artifactId>
171+
<version>1.5.0</version>
172+
<scope>system</scope>
173+
<systemPath>${java.home}/../lib/tools.jar</systemPath>
174+
</dependency>
175+
</dependencies>
176+
</plugin>
177+
</plugins>
178+
</build>
179+
</profile>
180+
<profile>
181+
<id>modern-jdk</id>
182+
<activation>
183+
<jdk>[9,)</jdk>
184+
</activation>
185+
<properties>
186+
<javaapi.compiler.source>1.8</javaapi.compiler.source>
187+
<javaapi.compiler.target>1.8</javaapi.compiler.target>
188+
</properties>
189+
</profile>
190+
</profiles>
163191

164192
</project>

vm/JavaAPI/pom.xml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@
1313
<packaging>jar</packaging>
1414
<name>JavaAPI</name>
1515

16+
<properties>
17+
<maven.compiler.source>1.5</maven.compiler.source>
18+
<maven.compiler.target>1.5</maven.compiler.target>
19+
</properties>
20+
21+
<profiles>
22+
<profile>
23+
<id>modern-jdk</id>
24+
<activation>
25+
<jdk>[9,)</jdk>
26+
</activation>
27+
<properties>
28+
<maven.compiler.source>1.8</maven.compiler.source>
29+
<maven.compiler.target>1.8</maven.compiler.target>
30+
</properties>
31+
</profile>
32+
</profiles>
33+
1634
<build>
1735
<sourceDirectory>src</sourceDirectory>
1836
<plugins>
@@ -21,8 +39,8 @@
2139
<artifactId>maven-compiler-plugin</artifactId>
2240
<version>3.11.0</version>
2341
<configuration>
24-
<source>1.5</source>
25-
<target>1.5</target>
42+
<source>${maven.compiler.source}</source>
43+
<target>${maven.compiler.target}</target>
2644
<!-- Allow compiling java.* packages -->
2745
<compilerArgs>
2846
<arg>-Xlint:-options</arg>

0 commit comments

Comments
 (0)