Please update sonar-maven-plugin to at least version 2.3 - maven

I'm building a project in Jenkins with Sonar Integration.
Everything goes smoothly until the sonar analysis part. I get the following error:
[ERROR] Failed to execute goal
org.codehaus.mojo:sonar-maven-plugin:2.2:sonar (default-cli) on
project project-whatever: Can not execute SonarQube analysis:
Please update sonar-maven-plugin to at least version 2.3 -> [Help 1]
and then the build fails.
I must explain that I have no references to sonar in my project pom.xml. This has been done exclusively with Jenkins configuration.
I'm using the latest available versions both on Jenkins (1.599) and Sonar (5.0). All Jenkins plugins are updated.
Already looked for a way to update the sonar-maven-plugin version, but I canĀ“t find it: either it doesn't exist or I'm not looking at the right places...
Does anyone have any ideia how to work around this?

I was able to fix this issue by going into Manage Jenkins -> Configure System -> Scroll to the SonarQube section -> Click advanced -> fill in "Version of sonar-maven-plugin" with the verison you would like to use.....I used 2.5.

If you can change the root pom.xml, then following should work as well:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
More info in SonarQube docs

Related

Old version of checkstyle detected. Consider updating to >= v8.30

Small question regarding a SonarQube + Checkstyle warning please.
Currently, in my app, in my pom, I use the following Checkstyle plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<outputFile>.out/reports/checkstyle/checkstyle-result.xml</outputFile>
<outputDirectory>target/reports/checkstyle</outputDirectory>
<outputFileFormat>xml</outputFileFormat>
</configuration>
</plugin>
This plugin is doing its job, no worries there.
When I run SonarQube though, I get this warning
Old version of checkstyle detected. Consider updating to >= v8.30
For more information see: https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html
I obviously went to read the website, but I am still having hard time understanding.
The Checkstyle plugin I have is the latest known, version 3.1.2, checked on Maven central etc.
In SonarQube, I am running on the latest version, 8.9 LTS, with the latest version of Checkstyle plugin as well.
What am I missing please? Am I using some kind of wrong plugin?
It is a SonarQube plugin named sonar-checkstyle which needs to be installed or upgraded at the SonarQube server instance. The current version is 8.40.
Note: Refer to
https://docs.sonarqube.org/latest/setup/install-plugin/
https://docs.sonarqube.org/latest/instance-administration/plugin-version-matrix/
https://github.com/checkstyle/sonar-checkstyle
https://github.com/checkstyle/sonar-checkstyle/releases
Edit 1
Step 1
Firstly, there is a cache directory at <user_home>/.sonar/cache (for me on the Windows 10 is C:\Users\<myuser>\.sonar\cache), please delete all sub directories under this cache directory with purpose to let the org.sonarsource.scanner.maven:sonar-maven-plugin latest version download it from our SonarQube server instance and ensure that all related plugins are new and fresh after upgrading/installing at the SonarQube server instance. (Do not forget to restart it after finishing upgrading/installing to ensure all new are re-loaded)
Step 2
Secondly, make sure that we do not specify the org.sonarsource.scanner.maven:sonar-maven-plugin in our project pom.xml neither at the parent nor anywhere else with purpose to ensure that during executing, it will be a latest version which matches to our SonarQube server instance version.
Anyhow the formal document (https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/) also mentions about How to Fix Version of Maven Plugin as the following: -
How to Fix Version of Maven Plugin
It is recommended to lock down versions of Maven plugins:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>
<!--Version that matched with our Sonar server instance version -->
</version>
</plugin>
</plugins>
</pluginManagement>
</build>
The latest version is able to be browsed at https://search.maven.org/artifact/org.codehaus.mojo/sonar-maven-plugin or https://search.maven.org/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin The latest is version 3.9.0.2155 (Note: the version ?.y.z is matched with our Sonar server instance version)
Step 3
Last but not least, if our project is a multi-module projects there is a mentioned at the formal document (https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/) as the following: -
In some situations you may want to run the sonar:sonar goal as a
dedicated step. Be sure to use install as first step for multi-module
projects
mvn clean install
mvn sonar:sonar ...
Then there will be 2 steps here, mvn clean install first so that it is completed and then mvn sonar:sonar ... later on.
Edit 2
The maven-checkstyle-plugin is also able to specify the checkstyle version as mentioned at https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html with the significant sentence as
Maven Checkstyle plugin comes with a default Checkstyle version: for
maven-checkstyle-plugin 3.1.2, Checkstyle 8.29 is used by default.
Then the configuration for the maven-checkstyle-plugin will be like the following: -
<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>...choose your version...</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<build>
...
</project>
The latest version is able to be browsed at https://search.maven.org/artifact/com.puppycrawl.tools/checkstyle The latest is version 8.42.

Content package plugin fails on TeamCity

Recently encountered an issue plaguing local AEM deployment, namely the content-package-maven-plugin sometimes fails with the following error:
[ERROR] Missing response status information in response
Updating the content-package-maven-plugin to version 0.5.24 and Maven to 3.5.2, as it was required by the plugin, resolves the error on local environment.
When building the same code on TeamCity the content-package-maven-plugin plugin throws an error:
Filter root's ancestor '/apps' is not covered by any of the specified dependencies.
We're using AEM 6.3, and TeamCity has the appropriate Maven version.
Had the same problem, try using
<plugin>
...
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
...
<configuration>
...
<packageType>container</packageType>
<embeddedTarget>${package.root}/install/</embeddedTarget>
With packageType container it seems to work.
This is due to a bug in filevault plugin. https://issues.apache.org/jira/browse/JCRVLT-219
Temporary fix: under filevault-package-maven-plugin, provide the following configuration:
<configuration>
...
<failOnDependencyErrors>false</failOnDependencyErrors>
</configuration>

Sonar Maven not working (org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli)

I see I am not the only one having this problem from 14 hours ago.
At my office, other projects are failing too but the message shown make reference to sonar-maven-plugin:2.6:sonar
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project x: Unable to determine structure of project.
Any ideas?
Define in your parent pom.xml the previous version of the plugin, it seems the latest version 2.7 has an issue you can pin the version like this :
<pluginManagement>
<plugins>
:
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</pluginManagement>
This has been fixed in 2.7.1. You can check this JIRA issue.
I just got hit with this issue. There's some issue with the 2.7 plugin so I tried forcing Maven to use the 2.6 plugin via the command line as below. Or you can add to pom.xml
-> mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
It seems downgrading the plugin from 2.7 to 2.6 at jenkins/configure in the server solves the issue.
Thanks to all!

sonar.host.url not working with sonar-maven-plugin:2.7

After upgrading my POMs to sonar-maven-plugin:2.7 the configuration does not work any more. My configuration in settings.xml is like this:
<profile>
<id>sonar</id>
<properties>
<sonar.jdbc.url>jdbc:postgresql://my.server:5432/sonar</sonar.jdbc.url>
<sonar.jdbc.driverClassName>org.postgresql.Driver</sonar.jdbc.driverClassName>
<sonar.jdbc.username>xxxxx</sonar.jdbc.username>
<sonar.jdbc.password>yyyyy</sonar.jdbc.password>
<sonar.host.url>http://my.server</sonar.host.url>
</properties>
</profile>
The build is started with -Psonar of course. With version 2.6 everything is fine, with 2.7 I get
[INFO] --- sonar-maven-plugin:2.7:sonar (default-cli) # myproject ---
[INFO] User cache: C:\Users\me\.sonar\cache
[ERROR] SonarQube server 'http://localhost:9000' can not be reached
...
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project myproject: Fail to download libraries from server: java.net.ConnectException: Connection refused: connect -> [Help 1]
Starting the build with -X gives me the correct mojo configuration in both cases, especially the url is still correct in the log
[DEBUG] (f) sonarHostURL = http://my.server
Even deleting the mentioned caching directory does not help.
What can I do except of managing the plugin to version 2.6?
We are investigating the issue. Ticket was created: https://jira.sonarsource.com/browse/MSONAR-129
In the meantime you could either lock the SQ plugin to version 2.6 or pass all properties using command line.
Workaround: Adding -Dsonar.host.url=http://my.server:9000 to mvn command works for me
Better than disabling the plugin, you may fix the plugin version to 2.6, which works fine, taking into account sonar.host.url.
For instance, with Maven in my case:
<pluginManagement>
</plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
<!-- sonar.host.url not working with version 2.7 -->
</plugin>
</plugins>
</pluginManagement>
I use the full qualified goal in the CI server to run the sonar goals:
mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
Since we use the templates in TeamCity this is not so much of a disaster. Still we were a bit surprised by the event.
Both
mvn -Dsonar.host.url=http://localhost:9000 org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
and
mvn -Dsonar.host.url=http://localhost:9000 org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
worked for me :
Instead of reconfiguring all jobs I disabled sonar for all jobs until this gets fixed. I added
<sonar.skip>true</sonar.skip>
to the sonar profile in settings.xml.

Maven Error " annotations are not supported....."

This is one of the most annoying errors ? What I can understand is that I am using a lower version of Java for compiling. How can I specify java version for maven ?
Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
(default-compile) on project
springAopMavenDemo: Compilation
failure D:\JAVA
Stuffs\projects\springAopMavenDemo\src\main\java\service\EmployeeServiceImpl.java:[13,1]
annotations are not supported in
-source 1.3 (use -source 5 or higher to enable annotations) #Service
-> [Help 1]
To see the full stack trace of the
errors, re-run Maven with the -e
switch. Re-run Maven using the -X
switch to enable full debug logging.
For more information about the errors
and possible solutions, please read
the following articles: [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I really appreciate any help......I am using NetBeans 7.0 and Maven 3
You need to tell maven which version of java the source should be compiled to
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
You are using some annotated code in your java, but compiling in your ide is using source java 1.3 by passing an additional commandline parameter most likely
I had the same thing in intellij a while back
In netbeans config (sorry I am not a netbeans person) find where jdk/compiler setup is and change the command line arg
Update: quick net serach says it may be under Properties > Build > Compiling
emeraldjava answer is correct. However, I want to add two things:
First, you can set the source and target information as Maven properties:
<build>
...
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
Second, if you use the latest version of the Maven compiler plugin (2.3.2 for example), the default version for compiler is 1.5, so you will not need any additional configuration:
The Compiler Plugin is used to compile
the sources of your project. The
default compiler is javac and is used
to compile Java sources. Also note
that at present the default source
setting is 1.5 and the default target
setting is 1.5, independently of the
JDK you run Maven with.
(source)

Resources