We have Sonar and Jenkins located on the same machine, and Sonar analysis is run as Jenkins job post step. Jenkins jobs are built with Maven 3.0.5.
Everything was fine until we updated Sonar from 4.5.x to 5.1.2 yesterday.
After update sonar step failed with exception:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project TestApplication: Can not execute Sonar
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.codehaus.sonar:sonar-maven3-plugin:5.1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.sonar:sonar-maven3-plugin:jar:5.1.2
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.codehaus.sonar:sonar-maven3-plugin:jar:5.1.2
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Failure to find org.codehaus.sonar:sonar-maven3-plugin:pom:5.1.2 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
We figured out that there is actually 5.1 version of org.codehaus.sonar:sonar-maven3-plugin, but no 5.1.2 in maven repo.
Fix:
We managed to fix it with forcing org.codehaus.mojo:sonar-maven-plugin version to 2.6 through in our pom file, as advised on official Analyzing with Sonar doc
But since we have dozens of projects, there should be better solution rather than changing every single project's pom files
Ok, simple solution found:
In the maven repository (.m2) it was cached that latest version of org.codehaus.mojo:sonar-maven-plugin is 2.0, even though the latest one is 2.6. (in file .m2/repository/org/codehaus/mojo/sonar-maven-plugin/maven-metadata-central.xml
)
The old version differs a lot from the new one in the way it works (see Which sonar-maven-plugin version to use?)
We removed .m2/repository/org/codehaus/mojo/sonar-maven-plugin directory, so that newer version is downloaded.