Skip to content

Commit

Permalink
Issue #915: convert maven-checkstyle-plugin to ant
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed Oct 23, 2022
1 parent 46499e5 commit bddb85d
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .ci/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ sonarqube)
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN \
-Dmaven.test.failure.ignore=true \
-Dcheckstyle.skip=true -Dpmd.skip=true
-Dcheckstyle.ant.skip=true -Dpmd.skip=true
;;

git-diff)
Expand Down
40 changes: 40 additions & 0 deletions sevntu-checks/ant-phase-verify-sevntu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="phase-package" default="execute">

<condition property="checkstyle.ant.skip">
<isset property="checkstyle.ant.skip" />
</condition>

<target name="execute" unless="checkstyle.ant.skip">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"/>

<property name="check.config" location="sevntu-checks.xml"/>

<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa" />
</tstamp>
<echo level="info">Checkstyle started (${check.config}): ${STARTED}</echo>

<checkstyle config="${check.config}"
failOnViolation="false"
failureProperty="checkstyle.failure.property"
executeIgnoredModules="true"
>
<fileset dir="src"
includes="**/*"
excludes="test/resources/**/*,test/resources-noncompilable/**/*"/>
<formatter type="plain"/>
<formatter type="xml" toFile="${mvn.project.build.directory}/cs_sevntu_errors.xml"/>
</checkstyle>

<tstamp>
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle finished (${check.config}) : ${FINISHED}</echo>

<fail if="checkstyle.failure.property"
message="Checkstyle failed: ${checkstyle.failure.property}"
/>
</target>
</project>
45 changes: 45 additions & 0 deletions sevntu-checks/ant-phase-verify.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="phase-package" default="execute">

<condition property="checkstyle.ant.skip">
<isset property="checkstyle.ant.skip" />
</condition>

<target name="execute" unless="checkstyle.ant.skip">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"/>

<tstamp>
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa" />
</tstamp>
<echo level="info">Checkstyle started (${checkstyle.configLocation}): ${STARTED}</echo>

<checkstyle config="${checkstyle.configLocation}"
failOnViolation="false"
failureProperty="checkstyle.failure.property"
executeIgnoredModules="true"
>
<fileset dir="src"
includes="**/*"
excludes="test/resources/**/*,test/resources-noncompilable/**/*"/>
<formatter type="plain"/>
<formatter type="xml" toFile="${mvn.project.build.directory}/cs_errors.xml"/>
<property key="checkstyle.cache.file" file="${mvn.project.build.directory}/cachefile"/>
<property key="checkstyle.header.file" value="${checkstyle.header}"/>
<property key="checkstyle.regexp.header.file" value="${checkstyle.regexp.header}"/>
<property key="checkstyle.importcontrol.file" file="import-control.xml"/>
<property key="checkstyle.importcontroltest.file" file="import-control-test.xml"/>
<property key="checkstyle.suppressions.file" file="suppressions.xml"/>
<property key="checkstyle.suppressions-xpath.file" file="suppressions.xml"/>
</checkstyle>

<tstamp>
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
</tstamp>
<echo level="info">Checkstyle finished (${checkstyle.configLocation}) : ${FINISHED}</echo>

<fail if="checkstyle.failure.property"
message="Checkstyle failed: ${checkstyle.failure.property}"
/>
</target>
</project>
6 changes: 0 additions & 6 deletions sevntu-checks/checkstyle.properties

This file was deleted.

Binary file added sevntu-checks/output.txt
Binary file not shown.
94 changes: 42 additions & 52 deletions sevntu-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<!-- verify time version -->
<checkstyle.version>10.3.4</checkstyle.version>
<checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle_checks.xml</checkstyle.configLocation>
<checkstyle.plugin.version>3.2.0</checkstyle.plugin.version>
<checkstyle.header>https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java.header</checkstyle.header>
<checkstyle.regexp.header>https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java_regexp.header</checkstyle.regexp.header>
<antrun.plugin.version>3.1.0</antrun.plugin.version>
<sevntu.maven.plugin>RELEASE</sevntu.maven.plugin>
<maven.jacoco.plugin.version>0.8.7</maven.jacoco.plugin.version>
<maven.pmd.plugin.version>3.11.0</maven.pmd.plugin.version>
Expand Down Expand Up @@ -250,36 +252,33 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<artifactId>maven-antrun-plugin</artifactId>
<version>${antrun.plugin.version}</version>
<executions>
<execution>
<!-- https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
to run checkstyle validation in terminal please use command "mvn process-classes"
-->
<phase>process-classes</phase>
<id>ant-phase-verify</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
<goal>run</goal>
</goals>
<configuration>
<configLocation>${checkstyle.configLocation}</configLocation>
<failOnViolation>true</failOnViolation>
<linkXRef>false</linkXRef>
<propertiesLocation>checkstyle.properties</propertiesLocation>
<sourceDirectories>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
</sourceDirectories>
<excludes>**/test/resources/**/*,**/test/resources-noncompilable/**/*</excludes>
<target>
<property name="mvn.project.build.directory" value="${project.build.directory}" />
<property name="checkstyle.configLocation" value="${checkstyle.configLocation}" />
<property name="checkstyle.header" value="${checkstyle.header}" />
<property name="checkstyle.regexp.header" value="${checkstyle.regexp.header}" />
<ant antfile="ant-phase-verify.xml" />
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -873,7 +872,7 @@
<skipTests>true</skipTests>
<linkcheck.skip>true</linkcheck.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<checkstyle.skip>true</checkstyle.skip>
<checkstyle.ant.skip>true</checkstyle.ant.skip>
<pmd.skip>true</pmd.skip>
<xml.skip>true</xml.skip>
<forbiddenapis.skip>true</forbiddenapis.skip>
Expand All @@ -884,48 +883,39 @@
</profile>
<profile>
<id>selftesting</id>
<properties>
<checkstyle.skip>false</checkstyle.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<artifactId>maven-antrun-plugin</artifactId>
<version>${antrun.plugin.version}</version>
<executions>
<execution>
<id>ant-phase-verify</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="mvn.project.build.directory" value="${project.build.directory}" />
<ant antfile="ant-phase-verify-sevntu.xml" />
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.eclipse-cs.version}</version>
<version>${checkstyle.version}</version>
</dependency>
<!-- attention here is self-referencing, so be sure you did "mvn install" before "mvn verify -Pselftesting" -->
<dependency>
<dependency>
<groupId>com.github.sevntu-checkstyle</groupId>
<artifactId>sevntu-checks</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<!-- https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
to run checkstyle validation in terminal please use command "mvn process-classes"
-->
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<configLocation>sevntu-checks.xml</configLocation>
<failOnViolation>true</failOnViolation>
<linkXRef>false</linkXRef>
<sourceDirectories>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
</sourceDirectories>
<excludes>**/test/resources/**/*,**/test/resources-noncompilable/**/*</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit bddb85d

Please sign in to comment.