Error resolving version for plugin when trying to analyze Maven project

Hello,

I am trying to analyze my Maven project. I’ve downloaded SonarQube as zip, launched the server on localhost:8080.

pom.xml:

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

Now in my project root I type: .\mvnw clean verify sonar:sonar -Dsonar.projectKey=my-project-name -Dsonar.host.url=http://localhost:9000 -Dsonar.login=my-login-key

An error I receive:
[ERROR] Error resolving version for plugin '.host.url=http://localhost' from the repositories [local (C:\Users\Jacky\.m2\repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]

How to solve this issue? Thanks.

Hi,

Welcome to the community!

You don’t need to add that plugin to your pom. Can you remove it and try again?

Also, you’re aware that in a production environment, the SonarQube server should run on its own host, right?

 
Ann

Hi,

you don’t even need to configure the Sonarqube Maven plugin in your pom.
Maven will resolve it automatically when using the sonar:sonar goal and uses the latest version.

You may try this small test to see that it works without plugin config in pom =
Create a small test pom like that

<project xmlns="[http://maven.apache.org/POM/4.0.0"](http://maven.apache.org/POM/4.0.0%22)
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance%22)
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
[http://maven.apache.org/xsd/maven-4.0.0.xsd">](http://maven.apache.org/xsd/maven-4.0.0.xsd%22>)

<modelVersion>4.0.0</modelVersion>
<groupId>com.foo.bar</groupId>
<artifactId>foo-app</artifactId>
<version>1</version>

</project>

then call mvn sonar:sonar and the Sonarqube Maven plugin will be downloaded.

From your error message it seems there’s either a syntax or a configuration error.

Try this =
delete the plugin config from pom
then call (sonar.host.url is default so you don’t need it)
mvn clean verify sonar:sonar -Dsonar.projectKey=my-project-name -Dsonar.login=my-login-key

Gilbert

2 Likes

Hi, I’m having the same issue. I don’t have the sonar maven plugin configured in my pom. I’m just trying to run as suggested in the documentation for running a local analysis using

mvn clean verify sonar:sonar -Dsonar.host.url=http://localhost:8000 -Dsonar.projectKey=project key -Dsonar.projectName=projectname -Dsonar.token=sonartoken

Is there something I am missing?

Thanks

Hi @Derek_Jones,

Welcome to the community!

Please create a new thread will all your details, including your error message. Even better would be posting your entire analysis log.

 
Thx,
Ann

Hi @ganncamp, thank you, I will do that. Could you please just clarify where to find the analysis log please? I can’t find anything in sonarqube\logs

Hi @Derek_Jones,

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
HTH,
Ann

Thanks, It worked for me running it on my computer