SonarRunner Failing in Java 8 - gradle

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.

Related

Wrong Major Version number when running Sonar Scanner with Java 11

I'm currently migrating a project from java 8 to java 11, and have been using Sonar scanner, with gradle, to send the code to SonaQube. After migrating to Open JDK 11, I amd getting the following error when running the gradle sonarqube tasks:
java.lang.IllegalArgumentException: Unsupported class file major version 55
I have read online that the scanner should be run with jdk 8, even though the analysis can be run on an version of java files, but have not been able to figure this out.
Ideally, I would be able to run gradle sonarqube with the Java 11 JDK. I found another question seeming to have success with Java 11 using Maven, but their error is different, and I don't think their solution would apply to me.
Is this problem solvable, or will I need to wait for Sonar Scanner to have support for JDK 11?
If someone like me this will helpful.
Source code Java 8(55), with jenkins and sonarqube scanner.
My error was
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
.....
java.lang.IllegalArgumentException: Unsupported class file major version 55
Check this link : Why does sonar-scanner force the usage of the embedded JRE?
And Change your sonnar-scanner.bat or sonnar-scanner.sh
use_embedded_jre=false

SonarQube 5.6 with Java Project (JDK 1.6)

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)

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"
}

Integrating sonarqube with Jenkins

I am trying to run sonar sonar:sonar by integrating sonarqube and jenkins. While doing, am getting the below error.
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project iwm_common: Can not execute SonarQube analysis: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext -> [Help 1]
Jenkins version - 1.612
Sonarqube version - 3.6
JDK-1.7.0_76
Maven - 3.1.1
Jenkins WAR is deployed in server A and sonarqube is deployed in server B. I have not installed sonar-jenkins plugin in Jenkins.
Can anyone let me know whether sonar-jenkins plugin is mandatory to be installed in jenkins to integrate jenkins with any sonar server (eg:sonarqube).
If the answer is YES, then after installation of the required plugin, will adding the sonar server (eg:sonarqube) information under Manage Jenkins -> Configure system -> sonar resolve the above error ?
The error is related to sonar-maven-plugin and this plugin is not used in any of the project's pom.xml. Can anyone please explain whether this plugin gets referred as a part of sonar:sonar goal. Thanks.
The versions you specified are not compatible for running sonar analysis.
Please upgrade SonarQube version (current is 5.1.1) which requires
Java 1.7-1.8
SonarQube 5.0 or 5.1.1
Sonar-runner 2.4
Using latest version of sonarqube resolved the issue mentioned.

Code coverage is not being reported - Sonarqube 4.3.2

I have installed Sonarqube 4.3.2 on Linux Redhat, JDK 1.7_51 and used following plugins:
Checkstyle [checkstyle] 2.1
Cobertura [cobertura] 1.6.2,Java [java] 2.3
PMD [pmd] 2.2
SCM Activity [scmactivity] 1.7.1
Scm Stats [scmstats] 0.3.1
Running mvn sonar on java projects reports all other metrics except code coverage. What am i missing?
Earlier ran into java squid error with cobertura plugin 1.6.1, once i upgraded to 1.6.2 went past the error but still code coverage is not being reported.
Sonar has removed support for code coverage. you need to do coverage analysis on your own or by some tool and import these reports into sonar.
Please refer this : http://docs.codehaus.org/display/SONAR/C%23+Plugin
This can be the case for cobertura as well. Please check.

Resources