這裏的簡單問題。我想添加聲納在每個Maven版本上執行。我想:如何使用聲納Maven插件
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
</plugin>
和
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>5.1</version>
</plugin>
和
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
因爲)我無法弄清楚什麼插件做的和/或b)哪一個是目前的一個。
如果我只將以上內容添加到<build>
- ><plugins>
它不會被執行(因此插件沒有默認執行)。所以我當然加了<execution>
指令,而聲納被執行後,但有以下錯誤信息:
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
未能執行目標org.sonarsource.scanner.maven:聲納Maven的插件: 3.1.1:項目org.acme.project.build上的聲納(默認):無法執行Findbugs:此項目包含未編譯的Java源文件。
它似乎沒有我使用哪種階段(我試過validate
和compile
和test
和prepare-package
和package
即使不是全部的意義)。我確信在項目的任何地方都沒有源代碼生成。而靜態類得到編譯就好了。
我認爲問題可能是插件被執行的每個模塊,包括父pom項目。這很奇怪,因爲sonar:sonar
跳過了這個項目。
但該項目結構簡單,我無法找到任何不尋常的:
<groupId>group</groupId>
<artifactId>org.acme.project.build</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>org.acme.project</module>
</modules>
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>http://sonar.acme.org/</sonar.host.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
org.acme.project
除了有其自己的工件ID和父沒有該項目。該命令行是:mvn clean deploy -Dsonar.login=Wile.Coyote -Dsonar.password=*********** -Psonar
日誌顯示聲納始終執行之前安裝階段,這當然是遠遠早。
那麼,如何使用Sonar的Maven插件來分析我的代碼?
你得到的錯誤是用哪個插件? – nullpointer
@nullpointer使用'sonar-maven-plugin'。 –
我的意思是使用groupId的sonar-maven-plugin?你們一起使用它們三個嗎? – nullpointer