Skip to content

Commit 6f4c490

Browse files
SONARJAVA-6182 Switch Guava project used in ruling tests to Java 21 (#59)
1 parent a46171f commit 6f4c490

9 files changed

Lines changed: 28 additions & 90 deletions

File tree

.github/scripts/resolve-sonar-java-plugin-version.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99
workflow_dispatch:
1010
schedule:
11-
- cron: "30 1 * * *" # Run daily at 1:30 AM UTC
11+
- cron: "30 1 * * *"
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -33,8 +33,10 @@ jobs:
3333
id: build-step
3434
with:
3535
deploy-pull-request: true
36-
artifactory-reader-role: private-reader # Override default public-reader
37-
artifactory-deployer-role: qa-deployer # Override default public-deployer
36+
artifactory-reader-role: private-reader
37+
artifactory-deployer-role: qa-deployer
38+
use-develocity: ${{ env.USE_DEVELOCITY }}
39+
develocity-url: ${{ env.DEVELOCITY_URL }}
3840

3941
qa:
4042
needs: [build]
@@ -46,10 +48,8 @@ jobs:
4648
fail-fast: false
4749
matrix:
4850
item:
49-
- { name: "with Lastest SonarJava Plugin", profile: "without-sonarqube-project", java_plugin_version: "LATEST_MASTER" }
50-
- { 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]" }
52-
- { name: "with Prod SonarJava Plugin", profile: "without-sonarqube-project", java_plugin_version: "POM_PROPERTY" }
51+
- { name: "with Latest SonarJava Plugin", profile: "without-sonarqube-project" }
52+
- { name: "for SonarQube Project Only", profile: "only-sonarqube-project" }
5353
name: "QA Tests ${{ matrix.item.name }}"
5454
env:
5555
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
@@ -60,17 +60,7 @@ jobs:
6060
submodules: recursive
6161
- uses: jdx/mise-action@d6e32c1796099e0f1f3ac741c220a8b7eae9e5dd # v3.2.0
6262
with:
63-
working-directory: its/ruling
6463
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 }}
7464
- name: Get GitHub Token for QA Licenses
7565
id: secrets
7666
uses: SonarSource/vault-action-wrapper@v3
@@ -81,36 +71,28 @@ jobs:
8171
id: configure-maven
8272
uses: SonarSource/ci-github-actions/config-maven@v1
8373
with:
84-
artifactory-reader-role: private-reader # Override default public-reader
85-
- name: Get Sonar Java plugin version
86-
id: resolve-sonar-java-plugin-version
87-
run: |
88-
VERSION=$(.github/scripts/resolve-sonar-java-plugin-version.sh "${{ matrix.item.java_plugin_version }}")
89-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
74+
artifactory-reader-role: private-reader
75+
use-develocity: ${{ env.USE_DEVELOCITY }}
76+
develocity-url: ${{ env.DEVELOCITY_URL }}
9077
- name: Run QA Tests
9178
working-directory: its/ruling
9279
env:
9380
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
9481
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
9582
MAVEN_OPTS: "-Xmx3g"
96-
SONAR_JAVA_VERSION: ${{ steps.resolve-sonar-java-plugin-version.outputs.version }}
97-
SONAR_RUNTIME: ${{ matrix.item.sonar-runtime || 'LATEST_RELEASE' }}
9883
run: |
9984
mvn package --batch-mode \
10085
"-Pit-ruling,${{ matrix.item.profile }}" \
101-
"-Dsonar.java.version=${SONAR_JAVA_VERSION}" \
102-
"-Dorchestrator.artifactory.accessToken=${ARTIFACTORY_ACCESS_TOKEN}" \
103-
"-Dsonar.runtimeVersion=${{ env.SONAR_RUNTIME }}" \
86+
"-Dsonar.runtimeVersion=LATEST_RELEASE" \
10487
"-Dmaven.test.redirectTestOutputToFile=false" \
105-
"-DbuildNumber=${BUILD_NUMBER}" \
10688
-B -e -V \
10789
"-Dparallel=methods" \
10890
"-DuseUnlimitedThreads=true"
10991
- name: Upload ruling artifacts on failure
11092
if: failure()
11193
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.5.0
11294
with:
113-
name: ruling-actual-${{ matrix.item.profile }}-${{ matrix.item.java_plugin_version }}
95+
name: ruling-actual-${{ matrix.item.profile }}
11496
path: its/ruling/target/actual/**/*
11597

11698
promote:

.gitmodules

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[submodule "its/sources"]
22
path = its/sources
33
url = https://github.com/SonarSource/ruling_java.git
4-
branch = se-engine

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To submit a contribution, create a pull request for this repository. Please make
3131

3232
### Build the Project and Run Unit Tests
3333

34-
Requirements: Java 17
34+
Requirements: Java 21
3535

3636
To build the plugin and run its unit tests, execute this command from the project's root directory:
3737

@@ -47,7 +47,7 @@ To run the test, first make sure the submodules are checked out:
4747

4848
git submodule update --init --recursive
4949

50-
Then, ensure that the `JAVA_HOME` environment variable is set for the ruling tests execution and that it points to your local JDK 17 installation.
50+
Then, ensure that the `JAVA_HOME` environment variable is set for the ruling tests execution and that it points to your local JDK 21 installation.
5151
Failing to do so will produce inconsistencies with the expected results.
5252

5353
From the `its/ruling` folder, launch the ruling tests:

its/ruling/mise.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

its/ruling/pom.xml

Lines changed: 1 addition & 15 deletions
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,!org.sonar.java.it.JavaRulingTest#guava</test>
117+
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server</test>
118118
</configuration>
119119
</plugin>
120120
</plugins>
@@ -134,20 +134,6 @@
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>
151137
</profiles>
152138

153139
</project>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void guava() throws Exception {
132132
MavenBuild build = test_project(projectKey, projectName);
133133
build
134134
// by default guava is compatible with java 6, however this is not supported with JDK 17+
135-
.setProperty("java.version", "1.7")
135+
.setProperty("java.version", "1.8")
136136
.setProperty("maven.javadoc.skip", "true")
137137
// use batch
138138
.setProperty("sonar.java.experimental.batchModeSizeInKB", "8192");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"com.google.guava:guava:src/com/google/common/collect/StandardTable.java": [
3+
131
4+
],
5+
"com.google.guava:guava:src/com/google/common/eventbus/SubscriberRegistry.java": [
6+
198
7+
],
8+
"com.google.guava:guava:src/com/google/common/reflect/ClassPath.java": [
9+
395
10+
]
11+
}

0 commit comments

Comments
 (0)