Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ plugin compatibility issue with Maven build by Java 8 version #2301

Closed
dlt-lee opened this issue Jan 21, 2022 · 7 comments
Closed

C++ plugin compatibility issue with Maven build by Java 8 version #2301

dlt-lee opened this issue Jan 21, 2022 · 7 comments
Labels

Comments

@dlt-lee
Copy link

dlt-lee commented Jan 21, 2022

Describe the bug
our one project source code is written by java 8 and build by Maven
I use:
mvn.cmd \pom.xml -X clean package org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar checkstyle:checkstyle findbugs:findbugs pmd:pmd
It works normally on sonarqube without CXX plugin
But it failed when install CXX plugin
log:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project dms_autobuild: The plugin [cxx] does not support Java 1.8.0_202: org/sonar/plugins/cxx/CxxPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project dms_autobuild: The plugin [cxx] does not support Java 1.8.0_202

My systyem:
JAVA_HOME_8_X64:C:\Program Files\Java\jdk1.8.0_202
java:C:\Program Files\Java\jdk-11.0.13\jre
jdk:C:\Program Files\Java\jdk-11.0.13

I try to set sonar.java.jdkHome=C:\Program Files\Java\jdk-11.0.13 but it seems not working.

Could you help me to solve this issue?
Thanks

Expected behavior
It can work normally

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. windows]
  • SonarQube version: [e.g. 8.9.0]
  • cxx plugin version: [e.g. 2.0.6]
@guwirth
Copy link
Collaborator

guwirth commented Jan 21, 2022

Hello @dlt-lee,

Please have a look to:

only tested with Java 11
Message "The plugin [cxx] does not support Java 1.8.0, UnsupportedClassVersionError". To solve this download OpenJDK 11 und unzip it (http://jdk.java.net/archive/). Point with the JAVA_HOME environment variable to the Java 11 location.

Hope this helps!

Regards,

@dlt-lee
Copy link
Author

dlt-lee commented Jan 21, 2022

Hello @dlt-lee,

Please have a look to:

only tested with Java 11
Message "The plugin [cxx] does not support Java 1.8.0, UnsupportedClassVersionError". To solve this download OpenJDK 11 und unzip it (http://jdk.java.net/archive/). Point with the JAVA_HOME environment variable to the Java 11 location.

Hope this helps!

Regards,

There are some projects share with this SQ. So I can't exclude C++ fromSQ.
A kind of project was written by Javas8 and ws complied by maven. So I csn't upgrade JAVA_HOME to Java 11.

Do you hae other soluation to solve it?
Thanks
BRGs
LI Zhuo

@guwirth
Copy link
Collaborator

guwirth commented Jan 21, 2022

Hi @dlt-lee,

there is no problem to upgrade to Java 11 because it’s backward compatible to Java 8.
The Java version of the scanner has nothing to do with the version you are using in your projects.

Regards,

@dlt-lee
Copy link
Author

dlt-lee commented Jan 22, 2022

Hi @dlt-lee,

there is no problem to upgrade to Java 11 because it’s backward compatible to Java 8. The Java version of the scanner has nothing to do with the version you are using in your projects.

Regards,

Unfortunately,our code can not be compiled by Java 11. It only works on java8 like CXX plugin only works on 11.
I read the https://docs.sonarqube.org/latest/analysis/languages/java/ but still can't find which part is suit for my case.I use scanner-maven for it.I still need maven8 to build our source code.
I use 8.9LTS and don't have any plan to upgrade till now.
SQ is shareed by our team python、Java、C++、Unity、C#....need analysis by it.So I can't remove language from this instance

Thanks
Looking forward your feedback

@dlt-lee
Copy link
Author

dlt-lee commented Jan 22, 2022

Hi @dlt-lee,
there is no problem to upgrade to Java 11 because it’s backward compatible to Java 8. The Java version of the scanner has nothing to do with the version you are using in your projects.

Regards,

Hi @guwirth
Unfortunately,our code can not be compiled by Java 11. It only works on java8 like CXX plugin only works on 11. I read the https://docs.sonarqube.org/latest/analysis/languages/java/ but still can't find which part is suit for my case.I use scanner-maven for it.I still need maven8 to build our source code. I use 8.9LTS and don't have any plan to upgrade till now. SQ is shareed by our team python、Java、C++、Unity、C#....need analysis by it.So I can't remove language from this instance

Thanks Looking forward your feedback

@dlt-lee dlt-lee closed this as completed Jan 22, 2022
@dlt-lee
Copy link
Author

dlt-lee commented Jan 22, 2022

Still need you help

@dlt-lee dlt-lee reopened this Jan 22, 2022
@guwirth
Copy link
Collaborator

guwirth commented Jan 22, 2022

Hi @dlt-lee,

the SonarQube docu is saying (see links above):

Project's specific JDK

In some situations, you might have to analyze a project built with a different version of Java than the one executing the analysis. The most common case is to run the analysis with Java 11, while the project itself uses Java 8 or before for its build. This case is normally automatically handled when using Maven or Gradle, as well as with any flavor of SonarLint.

If it is your case, and you are NOT using Maven or Gradle, you will need to set the property sonar.java.jdkHome manually (see below). By doing this you'll specify which JDK classes the analyzer must refer to during the analysis. Not setting this property, while it would have been required, usually leads to inconsistent or even impossible to fix issues being reported, especially in relation with native JDK classes.

When setting sonar.java.jdkHome, you need to provide the path to the JDK directory used by the project being analyzed, if different from the Java runtime executing the analysis. For example, for a Java 8 project, by setting it as follow: sonar.java.jdkHome=/usr/lib/jvm/jdk1.8.0_211

Maven or Gradle

We suggest basing your whole build on Java 11. If that's not compatible, you can have a dedicated script for the analysis that overrides the JAVA_HOME environment variable just before running it. See the following examples:

Maven

mvn verify ...
export JAVA_HOME=/path/to/java11
mvn sonar:sonar ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants