Skip to content

Commit a46171f

Browse files
SONARJAVA-6036 : Build with Java 21 to fix the CI. (#55)
1 parent 5adbbee commit a46171f

7 files changed

Lines changed: 37 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
item:
4949
- { name: "with Lastest SonarJava Plugin", profile: "without-sonarqube-project", java_plugin_version: "LATEST_MASTER" }
5050
- { name: "for SonarQube Project Only", profile: "only-sonarqube-project", java_plugin_version: "LATEST_MASTER" }
51+
- { name: "for Guava Project Only", profile: "only-guava-project", java_plugin_version: "LATEST_MASTER", java_version: "17", sonar-runtime: "LATEST_RELEASE[2025.4]" }
5152
- { name: "with Prod SonarJava Plugin", profile: "without-sonarqube-project", java_plugin_version: "POM_PROPERTY" }
5253
name: "QA Tests ${{ matrix.item.name }}"
5354
env:
@@ -61,6 +62,15 @@ jobs:
6162
with:
6263
working-directory: its/ruling
6364
version: 2025.7.12
65+
- name: Override Java version for specific profiles
66+
if: ${{ matrix.item.java_version }}
67+
run: |
68+
# We must 'cd' into the target directory because mise 'use' commands are
69+
# scoped to the current working directory. Changing directories ensures
70+
# the java version is pinned specifically for the 'its/ruling' path
71+
# by creating/updating a local .mise.toml file there.
72+
cd its/ruling
73+
mise use java@${{ matrix.item.java_version }}
6474
- name: Get GitHub Token for QA Licenses
6575
id: secrets
6676
uses: SonarSource/vault-action-wrapper@v3
@@ -84,12 +94,13 @@ jobs:
8494
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
8595
MAVEN_OPTS: "-Xmx3g"
8696
SONAR_JAVA_VERSION: ${{ steps.resolve-sonar-java-plugin-version.outputs.version }}
97+
SONAR_RUNTIME: ${{ matrix.item.sonar-runtime || 'LATEST_RELEASE' }}
8798
run: |
8899
mvn package --batch-mode \
89100
"-Pit-ruling,${{ matrix.item.profile }}" \
90101
"-Dsonar.java.version=${SONAR_JAVA_VERSION}" \
91102
"-Dorchestrator.artifactory.accessToken=${ARTIFACTORY_ACCESS_TOKEN}" \
92-
"-Dsonar.runtimeVersion=LATEST_RELEASE" \
103+
"-Dsonar.runtimeVersion=${{ env.SONAR_RUNTIME }}" \
93104
"-Dmaven.test.redirectTestOutputToFile=false" \
94105
"-DbuildNumber=${BUILD_NUMBER}" \
95106
-B -e -V \
@@ -115,4 +126,4 @@ jobs:
115126
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
116127
steps:
117128
- name: Promote artifacts
118-
uses: SonarSource/ci-github-actions/promote@v1
129+
uses: SonarSource/ci-github-actions/promote@v1

its/ruling/mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[tools]
2-
java = "17.0"
2+
java = ["21", "17"]

its/ruling/pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<groupId>org.apache.maven.plugins</groupId>
115115
<artifactId>maven-surefire-plugin</artifactId>
116116
<configuration>
117-
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server</test>
117+
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server,!org.sonar.java.it.JavaRulingTest#guava</test>
118118
</configuration>
119119
</plugin>
120120
</plugins>
@@ -134,6 +134,20 @@
134134
</plugins>
135135
</build>
136136
</profile>
137+
<profile>
138+
<id>only-guava-project</id>
139+
<build>
140+
<plugins>
141+
<plugin>
142+
<groupId>org.apache.maven.plugins</groupId>
143+
<artifactId>maven-surefire-plugin</artifactId>
144+
<configuration>
145+
<test>org.sonar.java.it.JavaRulingTest#guava</test>
146+
</configuration>
147+
</plugin>
148+
</plugins>
149+
</build>
150+
</profile>
137151
</profiles>
138152

139153
</project>

its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void guava() throws Exception {
131131
String projectKey = "com.google.guava:guava";
132132
MavenBuild build = test_project(projectKey, projectName);
133133
build
134-
// by default guava is compatible with java 6, however this is not supported with JDK 17
134+
// by default guava is compatible with java 6, however this is not supported with JDK 17+
135135
.setProperty("java.version", "1.7")
136136
.setProperty("maven.javadoc.skip", "true")
137137
// use batch
@@ -175,7 +175,7 @@ public void apache_commons_beanutils() throws Exception {
175175
String projectName = "commons-beanutils";
176176
MavenBuild build = test_project("commons-beanutils:commons-beanutils", projectName);
177177
build
178-
// by default it can not be built with jdk 17 without changing some plugin versions
178+
// by default it can not be built with recent JDK versions without changing some plugin versions
179179
.setProperty("maven-bundle-plugin.version", "5.1.4")
180180
// use batch
181181
.setProperty("sonar.java.experimental.batchModeSizeInKB", "8192");

java-symbolic-execution/java-symbolic-execution-checks-test-sources/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
<groupId>org.apache.maven.plugins</groupId>
3737
<artifactId>maven-compiler-plugin</artifactId>
3838
<configuration>
39-
<release>17</release>
40-
<source>17</source>
41-
<target>17</target>
39+
<release>21</release>
4240
<annotationProcessorPaths>
4341
<path>
4442
<groupId>org.projectlombok</groupId>

java-symbolic-execution/java-symbolic-execution-plugin/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<name>SonarQube Java :: Symbolic Execution Plugin</name>
1515

1616
<properties>
17-
<maven.compiler.source>17</maven.compiler.source>
18-
<maven.compiler.target>17</maven.compiler.target>
17+
<maven.compiler.source>21</maven.compiler.source>
18+
<maven.compiler.target>21</maven.compiler.target>
1919
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2020
<maven.deploy.skip>false</maven.deploy.skip>
2121
</properties>
@@ -94,8 +94,8 @@
9494
<plugin>
9595
<artifactId>maven-compiler-plugin</artifactId>
9696
<configuration>
97-
<source>17</source>
98-
<target>17</target>
97+
<source>21</source>
98+
<target>21</target>
9999
</configuration>
100100
</plugin>
101101
<plugin>

mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tools]
2-
java = "23"
2+
java = "21"
33
maven = "3.9"

0 commit comments

Comments
 (0)