简体   繁体   中英

Running sonar analysis with mvn sonar:sonar ignores sonar-project.properties

Latest 3.3 sonar-maven-plugin and 5.6 LTS as web server.
Running sonar analysis with mvn sonar:sonar ( Scanner for Maven )
ignores sonar-project.properties file. (with many parameters https://docs.sonarqube.org/display/SONAR/Analysis+Parameters )

Is it that the expected behavior?
So do I have to configure all sonar parameters within pom.xml files?

That is correct: the scanner for Maven ignores the sonar-project.properties file.

To pass analysis parameters when using the scanner for Maven, set them as <properties> in the pom.xml , for example:

<properties>
    <sonar.host.url>http://yourserver</sonar.host.url>
</properties>

Or, you could also pass parameters using -D on the command line, for example:

mvn sonar:sonar -Dsonar.host.url=http://yourserver

Other way would be to configure reading via Maven Properties Plugin

Q&A

   <build>    
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>sonar-project.properties</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM