jenkins the definitive guide

(Jeff_L) #1

In Maven 2, you could add something like the following to the section:


<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<configLocation>
src/main/config/company-checks.xml
</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>

For a Maven 3 project, you need to add the plugin to the element of the


section of the maven-site-plugin:
<project>
<properties>
<sonar.url>http://buildserver.acme.org:9000</sonar.url>
</properties>
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-2</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<configLocation>
${sonar.url}/rules_configuration/export/java/My_Rules/checkstyle.xml
</configLocation>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
</project>

Now, running mvn checkstyle:checkstyle or mvn site will analyse your source code and
generate XML reports that Jenkins can use.

Free download pdf