SonarQube 5.6 with Java Project (JDK 1.6) - sonarqube

I want to configure SonarQube for my maven project which is on jdk 1.6.
Can I use the latest SonarQube 5.6. It say code should be complied with jdk 1.8 only.
Is it possible to analyse code with older version of JDK with SonarQube on latest vesrion of JDK?
My project is compiled on jdk1.6. Do I need to use scanner which supports jdk1.6 because if I uses sonar-maven-plugin - 3.1.1 it gives error :
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar (default-cli) on project StreamDiffCLI: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar failed: Unable to load the mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0

I believe you're misreading the docs. You can compile your project with whatever version of Java you like. 1.4 even. But you must analyze with 8.

If you are installing Sonar-Cube with latest version with JDK 1.8 but your project is compatible to JDK 1.6 the use :
if project are supporting JDK 1.6, please use “sonar.java.source=1.6” in your configuration file to avoid rules applicable for JDK>1.6
e.g in build.xml (ANT)

Related

Want to exclude sonar plugin for specific project in bamboo build

I am supporting many teams for bamboo build including sonar. One of my team using CXX plugin .
Now we are facing issue after installing the plugin. Because many other team still depends on JDK 8 and CXX will support JDK 11. Is there any way to exclude CXX plugin for specific project or build ?
I tried -Dsonar.exclusions=/.h,/.c,**/.hh,/.hpp,/*.cc,.cxx,.cpp,.hxx but not success.
Error :
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project ABC: The plugin [cxx] does not support Java 1.8.0_312: 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]

"unable to resolve class" error after upgrading gradle 3 to gradle 4

Grails version: 3.2.9
Gradle initial version: 3.4.1 (everything works fine with this version)
Gradle upgraded version:4.10.3
Plugin: org.grails.grails-gsp
When I run gradlew war after upgrading gradle version to 4.10.3 I start to get the following error during execution of compileGroovyPages task:
dashboard_gsp.groovy: 2: unable to resolve class com.abnd.CarStatusEnum
# line 2, column 1.
import com.abnd.CarStatusEnum
^
Location of class com.abnd.CarStatusEnum is src/main/groovy/com/abnd/CarStatusEnum in the same project where the build is being run and gradlew war task completes successfully with gradle version 3.4.1. However when I upgrade gradle version to 4.10.3 then I start to get this error. Same happens with gradle version 4.1.
1) Any clue what can be the problem ?
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with grails version 3.x.x as with gradle 5.x.x I start to get even more issues as some grails plugins(like grails-gsp v3.3.2 which is latest stable version) use some features that have been deprecated in gradle 4.x.x and removed from gradle 5.x.x (see the error bellow)?
Failed to apply plugin [id 'org.grails.grails-gsp']
Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
1) Any clue what can be the problem ?
Yes. The error message is a clue that the GSP compiler can't find the enum class. This is because our plugin isn't compatible with Gradle 4.10.3.
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with
grails version 3.x.x
No. Those Gradle versions are not supported with the version of Grails you are using.
I hope that helps.

SonarQube analysis of guava v18 - InternalPrefixUnaryExpression cannot be cast to MethodInvocationTree

Using SonarQube 6.3.1 server, org.sonarsource.scanner.maven:sonar-maven-plugin:3.2 and 3.3.0.603, Apache Maven 3.5.0, Java version: 1.8.0_91, vendor: Oracle Corporation, running Fedora 25
Steps to reproduce:
git clone --branch v18.0 https://github.com/google/guava.git
cd guava
mvn -X org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar
Posting this error here as I'm not allowed to create issue sonarsource jira
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project guava-parent: SonarQube is unable to analyze file : '/home/rsvoboda/tmp/guava/guava/src/com/google/common/util/concurrent/Monitor.java': org.sonar.java.model.expression.InternalPrefixUnaryExpression cannot be cast to org.sonar.plugins.java.api.tree.MethodInvocationTree -> [Help 1]
To me this is bug, I could get further using workaround: -Dsonar.exclusions=**/com/google/common/util/concurrent/Monitor.java
As far as I can tell you are hitting this problem : https://jira.sonarsource.com/browse/SONARJAVA-2140 Which has been fixed in version 4.6 of SonarJava analyzer. (bundled version with SonarQube 6.3.1 is 4.5, consider upgrading it to latest version 4.9 at time of writing).
I can confirm that update of SonarJava analyzer via updatecenter to the latest version (4.9) available helps. Thank you #benzonico for help.

which versions of gradle, sonarqube and jacoco plugins are compatible

I am setting up a new multi-module gradle project to be built in jenkins and trying to get sonarqube analysing it but I have struck several incompatibility issues which I haven't been able to resolve.
I am looking at using
the sonarqube plugin because our existing projects get a warning about the deprecation of sonar-runner:
The 'sonar-runner' plugin has been deprecated and is scheduled to be removed in Gradle 3.0. please use the official plugin from SonarQube (the docs).
gradle 3
this simple example from sonarqube https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/java/gradle/java-gradle-simple/build.gradle
If I use gradle 3 I get this error: org.gradle.internal.jvm.Jvm.getRuntimeJar()Ljava/io/File;
If I use gradle 2.14 I get this error:
Caused by: java.io.IOException: Incompatible version 1007
This error in the past has been caused by an incompatibility between the jacoco and sonarqube plugins see JaCoCo SonarQube incompatible version 1007.
Which versions should I use?
FYI the release the SonarQube Scanner for Gradle 2.1 should happen very quickly and this version includes the support of Gradle 3.X. See https://jira.sonarsource.com/browse/SONARGRADL-16 which is already fixed.
You are not alone. I get the same issues as well. This works with gradle 2.12.
plugins {
id 'jacoco'
id 'java'
id "org.sonarqube" version "2.0.1"
}

SonarRunner Failing in Java 8

I have a java project with build system as Gradle. Recently we migrated to Java 8. After this migration sonarRunner task started failing with the following error :
05:10:51.823 INFO - Execute Findbugs 2.0.3...
05:10:56.502 INFO - Findbugs output report: /pathtoproject/build/sonar/findbugs-result.xml
The following errors occurred during analysis:
Unable to get XClass for java/util/function/BiConsumer
java.lang.ArrayIndexOutOfBoundsException: 1792
I started googling it and found out Findbugs 2.0.3 does not support I need to upgrade it and it was recommended that I should use Sonar server 5.x.x (my current sonar server is 5.4.x). I have some constraints yet I want my sonarRunner to be successful. Here are my constraints :
I can not upgrade the sonar server version (not in my hand)
Can not downgrade Java version.
I tried to search how to just upgrade the findbugs version in SonarRunner plugin that also I could not find. Please help me.

Resources