forked from phoedos/pmd
pmd (build): Turn pmd-build into mvn plugin
Turning this set of classes into a Maven plugin has been incredibly easy (less than 30 minutes actually) and allow us to simplify a little bit the pom.xml configuration. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7534 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
52
pmd/pom.xml
52
pmd/pom.xml
@ -274,6 +274,7 @@
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
@ -301,37 +302,6 @@
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>generate-ruleset-as-xdocs</id>
|
||||
<phase>pre-site</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo>PMD specific tasks: generating xdocs from rulesets</echo>
|
||||
<mkdir dir="${project.build.directory}/generated-xdocs/"/>
|
||||
<copy toDir="${project.build.directory}/generated-xdocs/"
|
||||
overwrite="true"
|
||||
verbose="true">
|
||||
<fileset dir="${src.xdocs.dir}"/>
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${project.version}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<ant antfile="tools/ant/generate-pmd-xdoc.xml">
|
||||
<property name="siteXml"
|
||||
value="src/site/site.pre.xml"/>
|
||||
<property name="rules.src"
|
||||
value="src/main/resources/rulesets/"/>
|
||||
<property name="target"
|
||||
value="${project.build.directory}/generated-xdocs/rules" />
|
||||
<property name="lib"
|
||||
value="${basedir}/tools/lib" />
|
||||
</ant>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>move-index-and-delete-generated-xdocs</id>
|
||||
<phase>site</phase>
|
||||
@ -388,12 +358,16 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- As Clover can be quite an hassle, know that you can skip it
|
||||
by using the following option when running mvn:
|
||||
$ mvn clean -Dmaven.clover.skip=true site
|
||||
-->
|
||||
<plugin>
|
||||
<groupId>com.atlassian.maven.plugins</groupId>
|
||||
<artifactId>maven-clover2-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<jdk>1.5</jdk>
|
||||
<jdk>1.6</jdk>
|
||||
<licenseLocation>tools/config/clover2.license</licenseLocation>
|
||||
</configuration>
|
||||
<executions>
|
||||
@ -436,7 +410,19 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>pmd</groupId>
|
||||
<artifactId>pmd-build</artifactId>
|
||||
<version>0.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>pre-site</phase>
|
||||
<goals>
|
||||
<goal>pmd-pre-site</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
@ -5,6 +5,7 @@
|
||||
<artifactId>pmd-build</artifactId>
|
||||
<name>PMD</name>
|
||||
<version>0.4</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<description>
|
||||
<![CDATA[
|
||||
This small subproject regroup most of the stuff needed to build pmd.
|
||||
@ -72,6 +73,12 @@ only if you modify the java code.
|
||||
<version>4.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
64
pmd/tools/src/net/sourceforge/pmd/maven/PmdPreSite.java
Normal file
64
pmd/tools/src/net/sourceforge/pmd/maven/PmdPreSite.java
Normal file
@ -0,0 +1,64 @@
|
||||
package net.sourceforge.pmd.maven;
|
||||
|
||||
import net.sourceforge.pmd.build.PmdBuildException;
|
||||
import net.sourceforge.pmd.build.PmdBuildTools;
|
||||
import net.sourceforge.pmd.build.RuleSetToDocs;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Says "Hi" to the user.
|
||||
* @goal pmd-pre-site
|
||||
*/
|
||||
public class PmdPreSite extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* Path to the existing site descriptor
|
||||
*
|
||||
* @parameter expression="${pmd.siteXml}" default-value="src/site/site.pre.xml"
|
||||
*/
|
||||
private String siteXml;
|
||||
|
||||
/**
|
||||
* Path to the existing site descriptor
|
||||
*
|
||||
* @parameter expression="${pmd.siteXml.target}" default-value="src/site/site.xml"
|
||||
*/
|
||||
private String siteXmlTarget;
|
||||
|
||||
/**
|
||||
* Path to the existing site descriptor
|
||||
*
|
||||
* @parameter expression="${pmd.siteTarget}" default-value="${project.build.directory}/generated-xdocs/rules"
|
||||
*/
|
||||
private String target;
|
||||
|
||||
/**
|
||||
* Path to the existing site descriptor
|
||||
*
|
||||
* @parameter expression="${pmd.rulesets}" default-value="src/main/resources/rulesets/
|
||||
*/
|
||||
private String rulesetsDirectory;
|
||||
|
||||
public void execute() throws MojoExecutionException {
|
||||
getLog().info("PMD: site generation preparation");
|
||||
getLog().debug("- target:" + target);
|
||||
getLog().debug("- siteXml:" + siteXml);
|
||||
getLog().debug("- rulesets:" + rulesetsDirectory);
|
||||
getLog().debug(" -siteXmlTarget" + siteXmlTarget);
|
||||
PmdBuildTools tool = new RuleSetToDocs();
|
||||
tool.setTargetDirectory(target);
|
||||
tool.setSiteXml(siteXml);
|
||||
tool.setRulesDirectory(rulesetsDirectory);
|
||||
tool.setSiteXmlTarget(siteXmlTarget);
|
||||
|
||||
try {
|
||||
tool.convertRulesets();
|
||||
tool.preSiteGeneration();
|
||||
}
|
||||
catch ( PmdBuildException e) {
|
||||
throw new MojoExecutionException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user