Hooks for the compile and verify phase. Run Checkstyle on itself as part of the verification process.

This commit is contained in:
Oliver Burn 2010-09-16 02:40:06 +00:00
parent a62935f3ea
commit 86cbe5bd16
3 changed files with 94 additions and 23 deletions

27
ant-phase-compile.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="phase-compile" default="execute">
<target name="execute">
<propertyfile file="${mvn.project.build.outputDirectory}/checkstylecompilation.properties">
<entry key="checkstyle.compile.version" value="${mvn.project.version}"/>
<entry key="checkstyle.compile.timestamp" type="date" value="now" pattern="E MMMM dd yyyy, HH:mm z"/>
</propertyfile>
<javadoc sourcefiles="src/checkstyle/com/puppycrawl/tools/checkstyle/api/TokenTypes.java"
encoding="iso-8859-1"
source="1.5"
failonerror="yes">
<classpath>
<pathelement location="${mvn.project.build.outputDirectory}"/>
<pathelement path="${mvn.compile_classpath}"/>
</classpath>
<doclet name="com.puppycrawl.tools.checkstyle.doclets.TokenTypesDoclet"
path="${mvn.project.build.outputDirectory}">
<param name="-destfile"
value="${mvn.project.build.outputDirectory}/com/puppycrawl/tools/checkstyle/api/tokentypes.properties"
/>
</doclet>
</javadoc>
</target>
</project>

38
ant-phase-verify.xml Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="phase-verify" default="execute">
<target name="execute">
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"
classpath="${mvn.runtime_classpath}"
/>
<delete file="${mvn.project.build.directory}/cachefile" />
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
<property name="check.config" location="checkstyle_checks.xml"/>
<property name="translation.severity" value="ignore"/>
<checkstyle config="${check.config}"
failOnViolation="false"
failureProperty="checkstyle.failure.property"
>
<fileset dir="src"
includes="checkstyle/**/*.java,checkstyle/**/*.properties,xdocs/**/*.xml"
excludes="**/Generated*.java,**/gui/*"/>
<formatter type="plain"/>
<formatter type="xml" toFile="${mvn.project.build.directory}/cs_errors.xml"/>
<classpath path="${mvn.runtime_classpath}"/>
<property key="checkstyle.cache.file" file="${mvn.project.build.directory}/cachefile"/>
<property key="checkstyle.header.file" file="java.header"/>
<property key="checkstyle.importcontrol.file" file="import-control.xml"/>
<property key="checkstyle.suppressions.file"
file="suppressions.xml"/>
</checkstyle>
<fail if="checkstyle.failure.property"
message="Checkstyle failed: ${checkstyle.failure.property}"
/>
</target>
</project>

52
pom.xml
View File

@ -167,43 +167,49 @@
<!-- version>1.3</version -->
<executions>
<execution>
<id>generate-checkstylecompilation.properties</id>
<id>ant-phase-compile</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<propertyfile file="${project.build.outputDirectory}/checkstylecompilation.properties">
<entry key="checkstyle.compile.version" value="${project.version}"/>
<entry key="checkstyle.compile.timestamp" type="date" value="now" pattern="E MMMM dd yyyy, HH:mm z"/>
</propertyfile>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<javadoc sourcefiles="src/checkstyle/com/puppycrawl/tools/checkstyle/api/TokenTypes.java"
encoding="iso-8859-1"
source="1.5"
failonerror="yes">
<classpath>
<pathelement location="${project.build.outputDirectory}"/>
<pathelement path="${compile_classpath}"/>
</classpath>
<doclet name="com.puppycrawl.tools.checkstyle.doclets.TokenTypesDoclet"
path="${project.build.outputDirectory}">
<param name="-destfile"
value="${project.build.outputDirectory}/com/puppycrawl/tools/checkstyle/api/tokentypes.properties"
<property name="mvn.project.build.outputDirectory"
value="${project.build.outputDirectory}"
/>
<property name="mvn.project.version"
value="${project.version}"
/>
</doclet>
</javadoc>
<property name="mvn.compile_classpath" refid="maven.compile.classpath"/>
<ant antfile="ant-phase-compile.xml"/>
</tasks>
</configuration>
</execution>
<execution>
<id>ant-phase-verify</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<property name="mvn.project.build.directory"
value="${project.build.directory}"
/>
<property name="mvn.project.version"
value="${project.version}"
/>
<property name="mvn.runtime_classpath" refid="maven.runtime.classpath"/>
<ant antfile="ant-phase-verify.xml"/>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
<version>1.7.1</version>
</dependency>
</dependencies>
</plugin>