Scanning Java 11 application

I am trying to scan an application coded in Java 11 using SonarCloud, the application is stored in Bitbucket.

This is the error I am getting:
‘’‘Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project (Project name): Fatal error compiling: invalid flag: --release → [Help 1]’’’

This is the example I am following: https://bitbucket.org/sonarsource/sample-maven-project/src/master/

I have tried changing the value for maven.compiler.source and maven.compiler.target to scan the appropriate version but it doesn’t want to compile. I have also scanned applications coded in Java 8 without any problems. Is there something that I need to update?

Hey there.

This tells me that Java 8 is probably being used to run your build/analysis (where indeed the --release flag was not supported) rather than Java 11.

Indeed, shame on us for not keeping this updated as we are using an old base image in the bitbucket-pipelines.yml file.

https://bitbucket.org/sonarsource/sample-maven-project/src/4eca2e555f4e7aa2343b2cb045c4fd3700d69875/bitbucket-pipelines.yml#lines-1

Let me suggest using a more up-to-date image (like 3.8.4-jdk-11) and I’ll follow-up internally about keeping these examples up to date

Colin