Skip to content

OLMIS-8280: Migrate SonarCloud analysis to Java 21 and drop axios from the Consul script - #5

Merged
mgrochalskisoldevelo merged 2 commits into
masterfrom
OLMIS-8280
Jul 28, 2026
Merged

OLMIS-8280: Migrate SonarCloud analysis to Java 21 and drop axios from the Consul script#5
mgrochalskisoldevelo merged 2 commits into
masterfrom
OLMIS-8280

Conversation

@denys1204

Copy link
Copy Markdown
Contributor

This PR bundles two BE-wide maintenance changes into one PR (BE builds take hours, so we batch them per the team decision).

1. Migrate SonarCloud analysis to Java 21

Why

SonarCloud Cloud dropped support for running analysis on Java 17, which broke the pipeline. The org.sonarqube 3.3 plugin runs the scanner inside the Gradle JVM, and Gradle 4.10.3 can't run on Java 21 — so the scanner couldn't be moved to a supported Java version in place.

What

Decouple the analysis from Gradle. Build, tests and the JaCoCo report stay in the Docker build; the analysis now runs via SonarSource/sonarqube-scan-action@v6, which provisions a Java 21 runtime for the scanner engine.

  • Run analysis via sonarqube-scan-action@v6 instead of ./gradlew sonarqube
  • Add sonar-project.properties reproducing the Gradle plugin's scope: sources src/main/java + src/main/resources, tests src/test/java + src/integration-test/java, sonar.java.source=17, JaCoCo coverage
  • Pass sonar.projectVersion from gradle.properties serviceVersion so New Code (Previous version) is tracked correctly, as the Gradle plugin used to do
  • Stop deleting ./build so sonar.java.binaries finds the compiled classes
  • Remove the now-unused org.sonarqube Gradle plugin, the sonarqube {} block and the dead sonar service in docker-compose.builder.yml
  • Bump checkout/setup-java/cache actions to v4; drop the redundant runner JDK step

2. Drop the axios dependency from the Consul registration script

Why

axios carries a recurring stream of security advisories. The registration script only makes a few HTTP calls to the internal Consul agent, so it doesn't need a third-party HTTP client.

What

Replace axios with the native Node http client, mirroring the approach already taken in the UI repos and in openlmis-stockmanagement.

  • Remove axios from consul/package.json
  • Rewrite the request helper in consul/registration.js to use http.request; the request/retry behaviour is preserved
  • consul/config.json is untouched (it is service-specific)

Notes

  • Build, tests and coverage are unchanged — only the analysis step is affected.
  • sonar.java.libraries is not set (dependency jars live inside the Docker build), so expect a lower-precision warning for a subset of Java rules.

Run the analysis through SonarSource/sonarqube-scan-action@v6 (which provisions
a Java 21 runtime) instead of the org.sonarqube Gradle plugin, which ran the
scanner inside the Gradle 4.10.3 JVM and could not move to Java 21.

- Replace the ./gradlew sonarqube step with sonarqube-scan-action@v6
- Add sonar-project.properties (sources, tests, binaries, coverage)
- Pass sonar.projectVersion from gradle.properties serviceVersion so New Code
  (Previous version) is tracked correctly, as the Gradle plugin used to do
- Remove the now-unused org.sonarqube plugin/config and the dead sonar service
  in docker-compose.builder.yml
- Stop deleting ./build so sonar.java.binaries finds the compiled classes
- Bump checkout/setup-java/cache actions to v4 and drop the redundant JDK step
Replace the axios dependency with the native Node http client in
consul/registration.js and remove axios from consul/package.json, mirroring the
approach already taken in the UI repos and in openlmis-stockmanagement. The
script only talks to the internal Consul agent and the request/retry behaviour
is preserved.
@sonarqubecloud

Copy link
Copy Markdown

@denys1204 denys1204 self-assigned this Jul 28, 2026
@mgrochalskisoldevelo
mgrochalskisoldevelo merged commit 4d54b5f into master Jul 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants