We have a java 8 spring boot 2.7 maven 3.1 multi-module project which we are attempting to integrate with sonar using the supplied bitbucket pipeline instructions.
Using this image:
image: maven:3.3.9-jdk-8
we get this error:
ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo has been compiled by a more recent version of the Java Runtime (class file version 55.0)
Using this image:
image: maven:3-openjdk-17
or this image:
maven:3-amazoncorretto-21
Gives this error:
java.lang.ExceptionInInitializerError: Unable to make field private com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs accessible: module jdk.compiler does not "opens com.sun.tools.javac.processing" to unnamed module
Any ideas how to get java/maven working with sonar and bitbucket pipelines?
Our parent pom has this:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-jar-plugin.version>3.1.0</maven-jar-plugin.version>
<sonar.organization>xxxx</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
pipeline file is this:
image: maven:3-openjdk-17
clone:
depth: full # SonarQube Cloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarQube Cloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarQube Cloud
caches:
- maven
- sonar
script:
- mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
artifacts:
- target/**
pipelines:
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
'**':
- step: *build-test-sonarcloud