Skip to content

Commit fbc6581

Browse files
SONARJAVA-6012 Migrate ITs to Java 21 (#5407)
1 parent 02a391e commit fbc6581

File tree

9 files changed

+48
-24
lines changed

9 files changed

+48
-24
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@ jobs:
5454
strategy:
5555
fail-fast: false
5656
matrix:
57-
runner:
58-
- github-ubuntu-latest-m
59-
- github-windows-latest-m
60-
profile:
61-
- without-sonarqube-project
62-
- only-sonarqube-project
57+
item:
58+
- { runner: github-ubuntu-latest-m, profile: without-sonarqube-project }
59+
- { runner: github-ubuntu-latest-m, profile: only-sonarqube-project }
60+
- { runner: github-ubuntu-latest-m, profile: only-guava-project, java_version: 17, sonar-runtime: "LATEST_RELEASE[2025.4]" }
61+
- { runner: github-windows-latest-m, profile: without-sonarqube-project }
62+
- { runner: github-windows-latest-m, profile: only-sonarqube-project }
63+
- { runner: github-windows-latest-m, profile: only-guava-project, java_version: 17, sonar-runtime: "LATEST_RELEASE[2025.4]" }
6364
name: Ruling QA
6465
needs:
6566
- build
6667
if: ${{ needs.build.outputs.deployed }}
67-
runs-on: ${{ matrix.runner }}
68+
runs-on: ${{ matrix.item.runner }}
6869
permissions:
6970
id-token: write
7071
contents: write
@@ -77,8 +78,10 @@ jobs:
7778
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
7879
with:
7980
version: 2025.7.12
80-
- name: Select Java 17
81-
run: mise use java@17
81+
- name: Select Java Version
82+
env:
83+
JAVA_VERSION: ${{ matrix.item.java_version || '21' }}
84+
run: mise use "java@${{ env.JAVA_VERSION }}"
8285
- name: Configure Maven
8386
uses: SonarSource/ci-github-actions/config-maven@v1
8487
with:
@@ -96,9 +99,10 @@ jobs:
9699
env:
97100
MAVEN_OPTS: "-Xmx3g"
98101
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
102+
SONAR_RUNTIME: ${{ matrix.item.sonar-runtime || 'LATEST_RELEASE' }}
99103
run: |
100104
cd its/ruling
101-
mvn package --batch-mode "-Pit-ruling,${{ matrix.profile }}" -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dparallel=methods -DuseUnlimitedThreads=true
105+
mvn package --batch-mode "-Pit-ruling,${{ matrix.item.profile }}" "-Dsonar.runtimeVersion=${{ env.SONAR_RUNTIME }}" -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dparallel=methods -DuseUnlimitedThreads=true
102106
103107
plugin-qa:
104108
strategy:
@@ -107,8 +111,6 @@ jobs:
107111
item:
108112
- sq_version: LATEST_RELEASE
109113
java_version: 21
110-
- sq_version: LATEST_RELEASE
111-
java_version: 17
112114
- sq_version: DEV
113115
java_version: 21
114116
name: Plugin QA
@@ -306,8 +308,8 @@ jobs:
306308
working-directory: java-checks-test-sources
307309
run: |
308310
mvn clean compile test-compile --batch-mode
309-
- name: Select Java 17
310-
run: mise use java@17
311+
- name: Select Java 21
312+
run: mise use java@21
311313
- uses: SonarSource/ci-github-actions/config-maven@v1
312314
with:
313315
artifactory-reader-role: private-reader

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ To run tests locally follow these instructions.
5555

5656
### Java versions
5757

58-
You need `Java 25` to compile and run the Unit Tests of the project and `Java 17` run the Integration Tests (ITs).
59-
Note that `Java 21` can be used to build and test all modules except under `java-checks-test-sources` (as they require `Java 25`) and `its` (as they require `Java 17` because of SQ incompatibility).
58+
You need `Java 25` to compile and run the Unit Tests of the project and `Java 21` run most Integration Tests (ITs).
59+
Ruling test on Guava project require `Java 17`.
60+
Note that `Java 21` can be used to build and test all modules except under `java-checks-test-sources` (as they require `Java 25`).
6061

6162
### Build the Project and Run Unit Tests
6263

@@ -121,7 +122,7 @@ From the `its/ruling` folder, launch the ruling tests:
121122

122123
mvn clean install -Pit-ruling -DcommunityEditionTestsOnly=true
123124
# Alternatively
124-
JAVA_HOME=/my/local/java17/jdk/ mvn clean install -Pit-ruling -DcommunityEditionTestsOnly=true
125+
JAVA_HOME=/my/local/java21/jdk/ mvn clean install -Pit-ruling -DcommunityEditionTestsOnly=true
125126

126127
Note for internal contributors: in order to also execute the tests that depend on the SonarQube Server Enterprise Edition, use:
127128

@@ -172,7 +173,7 @@ mvn clean compile
172173
To run the tests, move to the [`its/autoscan`](its/autoscan) folder and run:
173174
```shell
174175
# cd its/autoscan
175-
# use Java 17!
176+
# use Java 21!
176177
mvn clean package --batch-mode --errors --show-version \
177178
--activate-profiles it-autoscan \
178179
-Dsonar.runtimeVersion=LATEST_RELEASE

its/autoscan/src/test/java/org/sonar/java/it/AutoScanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void javaCheckTestSources() throws Exception {
199199
softly.assertThat(newDiffs).containsExactlyInAnyOrderElementsOf(knownDiffs.values());
200200
softly.assertThat(newTotal).isEqualTo(knownTotal);
201201
softly.assertThat(rulesCausingFPs).hasSize(10);
202-
softly.assertThat(rulesNotReporting).hasSize(17);
202+
softly.assertThat(rulesNotReporting).hasSize(14);
203203

204204
/**
205205
* 4. Check total number of differences (FPs + FNs)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ruleKey": "S5738",
33
"hasTruePositives": true,
4-
"falseNegatives": 4,
4+
"falseNegatives": 3,
55
"falsePositives": 0
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ruleKey": "S6901",
3-
"hasTruePositives": false,
3+
"hasTruePositives": true,
44
"falseNegatives": 0,
55
"falsePositives": 0
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ruleKey": "S6913",
3-
"hasTruePositives": false,
3+
"hasTruePositives": true,
44
"falseNegatives": 0,
55
"falsePositives": 0
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ruleKey": "S6915",
3-
"hasTruePositives": false,
3+
"hasTruePositives": true,
44
"falseNegatives": 0,
55
"falsePositives": 0
66
}

its/ruling/pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<groupId>org.apache.maven.plugins</groupId>
109109
<artifactId>maven-surefire-plugin</artifactId>
110110
<configuration>
111-
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server</test>
111+
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server,!org.sonar.java.it.JavaRulingTest#guava</test>
112112
</configuration>
113113
</plugin>
114114
</plugins>
@@ -128,6 +128,20 @@
128128
</plugins>
129129
</build>
130130
</profile>
131+
<profile>
132+
<id>only-guava-project</id>
133+
<build>
134+
<plugins>
135+
<plugin>
136+
<groupId>org.apache.maven.plugins</groupId>
137+
<artifactId>maven-surefire-plugin</artifactId>
138+
<configuration>
139+
<test>org.sonar.java.it.JavaRulingTest#guava</test>
140+
</configuration>
141+
</plugin>
142+
</plugins>
143+
</build>
144+
</profile>
131145
</profiles>
132146

133147
</project>

its/ruling/src/test/resources/eclipse-jetty/java-S5738.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
"org.eclipse.jetty:jetty-project:jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java": [
1616
680
1717
],
18+
"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java": [
19+
198,
20+
216
21+
],
22+
"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java": [
23+
730
24+
],
1825
"org.eclipse.jetty:jetty-project:jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java": [
1926
1761
2027
]

0 commit comments

Comments
 (0)