0

I'm trying to set the projectkey via command line but Maven is ignoring it.

I tried to run this:

mvn sonar:sonar -Dsonar.projectKey=myprojectkey

but when I look at the output, it's using the project name of the POM for the project key not my parameter.

halfer
  • 19,824
  • 17
  • 99
  • 186
red888
  • 27,709
  • 55
  • 204
  • 392
  • Your command is certainly correct for overriding the project key. If you think otherwise, you must be overlooking something. If you have some proof to support your assumption, please share it and ping me back, I can probably point out what you overlooked. – janos Oct 05 '19 at 14:17

1 Answers1

0

Have you tried using Sonar Scanner for Maven? You can add it as a plugin under <build> as follows:

<build>
  <pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.4.0.905</version>
        </plugin>
    </plugins>
  </pluginManagement>
</build>

From what I've read, for Maven projects, your sonar.projectKey defaults to <groupId>:<artifactId> or you can define an analysis parameter under <properties>

<properties>
  <sonar.projectName>...</sonar.projectName>
</properties>
Ambro-r
  • 919
  • 1
  • 4
  • 14