-->

Why sonar-maven-plugin-3.0.1.jar cannot be found w

2020-07-24 05:20发布

问题:

We are currently including (reactivating) sonar in our continuous build process and we are experiencing some issues. In order to focus only on sonar I tried to make it work on an "HelloWorld" project but still without any success.

One jar (sonar-maven-plugin-3.0.1.jar) seems to be missing from repo1 and repo2. I've browse those locations and only pom can be found here.

Neither it can be found on the following url:

  • [http://www.java2s.com/Code/Jar/s/sonar.htm][1]
  • [http://mvnrepository.com/artifact/org.codehaus.sonar/sonar-maven-plugin/3.0.1][2]

So far I didn't found any archived version of this jar.

At this point any help is warmly welcome.

Here is my repo (only the org\codehaus\mojo part):

C:\maven-local-repo\org\codehaus\mojo>dir /s /b
C:\maven-local-repo\org\codehaus\mojo\maven-metadata-central.xml
C:\maven-local-repo\org\codehaus\mojo\maven-metadata-central.xml.sha1
C:\maven-local-repo\org\codehaus\mojo\mojo-parent
C:\maven-local-repo\org\codehaus\mojo\sonar-maven-plugin
C:\maven-local-repo\org\codehaus\mojo\mojo-parent\38
C:\maven-local-repo\org\codehaus\mojo\mojo-parent\38\mojo-parent-38.pom
C:\maven-local-repo\org\codehaus\mojo\mojo-parent\38\mojo-parent-38.pom.sha1
C:\maven-local-repo\org\codehaus\mojo\sonar-maven-plugin\3.0.1
C:\maven-local-repo\org\codehaus\mojo\sonar-maven-plugin\maven-metadata-central.xml
C:\maven-local-repo\org\codehaus\mojo\sonar-maven-plugin\maven-metadata-central.xml.sha1
C:\maven-local-repo\org\codehaus\mojo\sonar-maven-plugin\3.0.1\sonar-maven-plugin-3.0.1.pom
C:\maven-local-repo\org\codehaus\mojo\sonar-maven-plugin\3.0.1\sonar-maven-plugin-3.0.1.pom.sha1

Here is the output I get when executing mvn sonar:sonar -X:

+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.7.0_51
Java home: C:\Tools\jdk1.7.0_51\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
[DEBUG] Building Maven user-level plugin registry from: 'C:\Users\a89632\.m2\plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: 'C:\Tools\apache-maven-2.2.1\conf\plugin-registry.xml'
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'sonar'.
[DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
[DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
[INFO] org.codehaus.mojo: checking for updates from central
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Checking for pre-existing User-Agent configuration.
[DEBUG] Adding User-Agent configuration.
[DEBUG] Connecting to repository: 'Central' with url: 'http://repo1.maven.org/maven2/'.
[DEBUG] Using Proxy: ncproxy
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] artifact org.codehaus.mojo:sonar-maven-plugin: checking for updates from central
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Checking for pre-existing User-Agent configuration.
[DEBUG] Adding User-Agent configuration.
[DEBUG] Connecting to repository: 'Central' with url: 'http://repo1.maven.org/maven2/'.
[DEBUG] Using Proxy: ncproxy
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] sonar-maven-plugin: resolved to version 3.0.1 from repository central
[DEBUG] Trying repository central
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Checking for pre-existing User-Agent configuration.
[DEBUG] Adding User-Agent configuration.
[DEBUG] Connecting to repository: 'Central' with url: 'http://repo1.maven.org/maven2/'.
[DEBUG] Using Proxy: ncproxy
Downloading: http://repo1.maven.org/maven2//org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.pom
[DEBUG] attempting to create parent directories for destination: sonar-maven-plugin-3.0.1.pom.tmp
1/1K
1K downloaded  (sonar-maven-plugin-3.0.1.pom)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG]   Artifact resolved
[DEBUG] Retrieving parent-POM: org.codehaus.mojo:mojo-parent:pom:38 for project: org.codehaus.mojo:sonar-maven-plugin:pom:3.0.1 from the repository.
[DEBUG] Trying repository central
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Checking for pre-existing User-Agent configuration.
[DEBUG] Adding User-Agent configuration.
[DEBUG] Connecting to repository: 'Central' with url: 'http://repo1.maven.org/maven2/'.
[DEBUG] Using Proxy: ncproxy
Downloading: http://repo1.maven.org/maven2//org/codehaus/mojo/mojo-parent/38/mojo-parent-38.pom
[DEBUG] attempting to create parent directories for destination: mojo-parent-38.pom.tmp
4/32K
8/32K
12/32K
16/32K
20/32K
24/32K
28/32K
31/32K
32/32K
32K downloaded  (mojo-parent-38.pom)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG]   Artifact resolved
[DEBUG] Adding managed dependencies for org.codehaus.mojo:sonar-maven-plugin
[DEBUG]   org.apache.maven:maven-plugin-api:jar:2.2.1
[DEBUG]   junit:junit:jar:4.12:test
[DEBUG]   org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.4
[DEBUG] While downloading org.codehaus.mojo:sonar-maven-plugin:3.0.1
  This artifact has been relocated to org.sonarsource.scanner.maven:sonar-maven-plugin:LATEST.
  SonarQube plugin was moved to SonarSource organisation


[DEBUG] sonar-maven-plugin: resolved to version 3.0.1 from repository central
[DEBUG] Retrieving parent-POM: org.sonarsource.parent:parent:pom:26 for project: org.sonarsource.scanner.maven:sonar-maven-plugin:maven-plugin:3.0.1 from the repository.
[DEBUG] Trying repository central
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Checking for pre-existing User-Agent configuration.
[DEBUG] Adding User-Agent configuration.
[DEBUG] Connecting to repository: 'Central' with url: 'http://repo1.maven.org/maven2/'.
[DEBUG] Using Proxy: ncproxy
Downloading: http://repo1.maven.org/maven2//org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
[DEBUG] Unable to locate resource in repository
org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate resource in repository
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:139)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.apache.maven.artifact.manager.DefaultWagonManager.getRemoteFile(DefaultWagonManager.java:546)
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:427)
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:382)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
    at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:212)
    at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
    at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.io.FileNotFoundException: http://repo1.maven.org/maven2/org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1675)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1673)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1671)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1244)
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:122)
    ... 27 more
Caused by: java.io.FileNotFoundException: http://repo1.maven.org/maven2/org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1624)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:115)
    ... 27 more
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] Unable to find resource 'org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1' in repository central (http://repo1.maven.org/maven2)
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[INFO] Cannot find mojo descriptor for: 'sonar:sonar' - Treating as non-aggregator.
[DEBUG] 
org.apache.maven.plugin.PluginNotFoundException: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command: 
    mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there: 
    mvn deploy:deploy-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


    at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:253)
    at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
    at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
    at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:212)
    ... 18 more
[DEBUG] Wagons could not be registered as the extension container was never created
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype
[INFO]    task-segment: [sonar:sonar]
[INFO] ------------------------------------------------------------------------
[DEBUG] Trying repository central
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[DEBUG] Checking for pre-existing User-Agent configuration.
[DEBUG] Adding User-Agent configuration.
[DEBUG] Connecting to repository: 'Central' with url: 'http://repo1.maven.org/maven2/'.
[DEBUG] Using Proxy: ncproxy
Downloading: http://repo1.maven.org/maven2//org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
[DEBUG] Unable to locate resource in repository
org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate resource in repository
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:139)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.apache.maven.artifact.manager.DefaultWagonManager.getRemoteFile(DefaultWagonManager.java:546)
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:427)
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:382)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
    at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:212)
    at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
    at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:568)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.io.FileNotFoundException: http://repo1.maven.org/maven2/org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1675)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1673)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1671)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1244)
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:122)
    ... 30 more
Caused by: java.io.FileNotFoundException: http://repo1.maven.org/maven2/org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1624)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:115)
    ... 30 more
[DEBUG] Using Wagon implementation lightweight from default mapping for protocol http
[INFO] Unable to find resource 'org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1' in repository central (http://repo1.maven.org/maven2)
[DEBUG] Using mirror: http://repo1.maven.org/maven2/ (id: Central)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command: 
    mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there: 
    mvn deploy:deploy-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command: 
    mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there: 
    mvn deploy:deploy-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:544)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginNotFoundException: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command: 
    mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there: 
    mvn deploy:deploy-file -DgroupId=org.codehaus.mojo -DartifactId=sonar-maven-plugin -Dversion=3.0.1 -Dpackaging=maven-plugin -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


  org.codehaus.mojo:sonar-maven-plugin:maven-plugin:3.0.1

from the specified remote repositories:
  Central (http://repo1.maven.org/maven2/)


    at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:253)
    at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
    at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:568)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    ... 15 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
    at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:212)
    ... 21 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Feb 09 08:25:01 CET 2016
[INFO] Final Memory: 5M/122M
[INFO] ------------------------------------------------------------------------


  [1]: http://www.java2s.com/Code/Jar/s/sonar.htm
  [2]: http://mvnrepository.com/artifact/org.codehaus.sonar/sonar-maven-plugin/3.0.1

回答1:

Due to the shutdown of Codehaus project hosting the SonarQube Scanner for Maven (aka SonarQube Maven Plugin) was moved to its own groupId. The new groupId is org.sonarsource.scanner.maven.

org.codehaus.mojo was a special case since it is hardcoded into Maven so that you were able to use mvn sonar:sonar without any configuration.

To ease the transition period we continue to deploy a relocation pom to the old groupId. Unfortunately this relocation doesn't work for Maven 2. This is a known issue that will probably never be fixed since Maven 2 is EOL.

So you have several options:

  1. Update to Maven 3.x and benefit from the relocation
  2. Add org.sonarsource.scanner.maven in the <pluginGroup> section of your settings.xml and continue to use mvn sonar:sonar
  3. Declare <plugin> entry in your project pom.xml (or in corporate parent pom) and continue to use mvn sonar:sonar. Here it means you'll lock the version of the plugin that may be or not a good thing depending on your ability to update frequently you pom.xml.
  4. Use the full command line: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar instead of mvn sonar:sonar

Note that updating to Maven 3 (option 1) will allow you to benefit from the relocation as long as we are allowed to deploy the relocation pom. So I advice to do option 1 but then also consider option 2 or 3 or 4 to no more rely on the relocation.



回答2:

I used http://search.maven.org and found sonar-maven-plugin version 3.0.1.

I could follow the trace to https://repo1.maven.org/maven2/org/codehaus/sonar/sonar-maven-plugin/3.0.1/

Is that one the onoe you wish to use? That is the same as specified in your stack trace.

How is your maven setup? Do you have a HttpProxy in between? Can you grab the artifact with curl? etc..

From your stacktrace:

[DEBUG] Using Proxy: ncproxy
Downloading: http://repo1.maven.org/maven2//org/codehaus/mojo/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar

I suspect there is a discrepancy between using org.codehaus.mojo:sonar-maven-plugin and org.codehaus.sonar:sonar-maven-plugin. I believe the prior one was discontinued after version 2.7.1, which seems to give retired versions of 3.0 and 3.0.1



回答3:

I have the same problem at work. I fixed it by removing local repository (.m2 directory). We use JFrog Artifactory as a proxy so I also clear cache on it.



回答4:

Adding "org.sonarsource.scanner.maven in the section of your settings.xml and continue to use mvn sonar:sonar" fixed my issue.



回答5:

Incase you're using sonarQube 7.6 sonar runner 2.4 Maven 3.6 java Jdk 1.8

then you can confidently use the below set of codes in pom.xml file

<properties>
        <sonar.host.url>http://1localhost:9000/</sonar.host.url>
       </properties>

dependency details:

<dependency>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>3.6.0.1398</version>
              </dependency>

surely it will work. If your'e using pipeline project with sonar qube in jenkins then use below groovy code,

stage('CodeCoverage') {
         steps {
             bat "mvn sonar:sonar"
         }
     }