I try to execute the mvn sonar:sonar
command on a machine where Maven is configured to have no access to external repositories (in reality, this is not exactly the case, but it helps me to explain my problem).
So currently, if I run this command, I get the following error:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.codehaus.mojo:sonar-maven-plugin' 开发者_运维问答does not exist or no valid version could be found
I think it means that I have some incorrect metadata in my local repository, as I have a [local repo]\org\codehaus\mojo\sonar-maven-plugin\1.0-beta-1
directory (with the JAR inside, of course).
Have you any idea why my command is failing?
tech infos: Maven 2.2.1, Java 1.6, Sonar 2.1.2
Did you try the suggestions from the FAQ:
The plugin 'org.apache.maven.plugins:maven-sonar-plugin' does not exist or no valid version could be found
If you get this error message after launching the maven command line "mvn sonar:sonar" add the "-U" parameter to the command line. Maven will then update its local repository with the latest version of the Sonar Maven plugin.
If adding the "-U" parameter doesn't fix your issue, you've certainly encountered Maven bug MNG-4001. The only known workaround is to delete the org\codehaus\mojo directory in your local Maven repository. Of course, if your local Maven repository is synchronized with a repository manager like Nexus, this operation must be also done on the repository manager side.
Just as a hint for those running Sonar from Jenkins (using the plugin), we've seen the similar problem ourselves.
But as the official docs say: http://docs.sonarqube.org/display/SONAR/Analyzing+with+Maven in section: How to Fix Version of Maven Plugin
You can fix the version of sonar-maven-plugin in the Jenkins -> Configuration -> Sonar -> "Version of sonar-maven-plugin":
- for Maven 2 to: 1.0
- for Maven 3 to: 2.0
As a result it would skip the version resolution + lookup => prevent the problem reported here.
UPDATE:
Well, I just realized, it's applicable for any case not just jenkins. You can specify the version explicitly to prevent lookup.
My problem is resolved now since it was mainly a problem of maven metadata file.
The org/codehaus/mojo/sonar-maven-plugin
did not contains the correct maven-metadata.xml
file. Thus, Maven 2 was unable to know which version of the plugin was needed. Adding it resolved my issue.
精彩评论