Skip to content

Commit a48beaa

Browse files
rnveachmuhlba91
authored andcommitted
Issue #444: convert maven-checkstyle-plugin to ant
1 parent 51d6555 commit a48beaa

File tree

5 files changed

+127
-42
lines changed

5 files changed

+127
-42
lines changed

.ci/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ integration-tests)
2121
;;
2222

2323
nondex)
24-
mvn --fail-never clean nondex:nondex -Dcheckstyle.skip=true
24+
mvn --fail-never clean nondex:nondex -Dcheckstyle.ant.skip=true
2525
cat `grep -RlE 'td class=.x' .nondex/ | cat` < /dev/null > output.txt
2626
RESULT="$(cat output.txt | wc -c)"
2727
cat output.txt

config/ant-phase-verify-sevntu.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project name="phase-package" default="execute">
4+
<condition property="run">
5+
<or>
6+
<not>
7+
<isset property="checkstyle.ant.skip"/>
8+
</not>
9+
<isfalse value="${checkstyle.ant.skip}"/>
10+
</or>
11+
</condition>
12+
13+
<target name="execute" if="run">
14+
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"/>
15+
16+
<tstamp>
17+
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa" />
18+
</tstamp>
19+
<echo level="info">Checkstyle started (${checkstyle.sevntu.configLocation}): ${STARTED}</echo>
20+
21+
<checkstyle config="${checkstyle.sevntu.configLocation}"
22+
failOnViolation="false"
23+
failureProperty="checkstyle.failure.property"
24+
executeIgnoredModules="true"
25+
>
26+
<fileset dir="src"
27+
includes="**/*"
28+
excludes="test/resources/**/*,it/resources/**/*"/>
29+
<formatter type="plain"/>
30+
<formatter type="xml" toFile="${mvn.project.build.directory}/cs_sevntu_errors.xml"/>
31+
</checkstyle>
32+
33+
<tstamp>
34+
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
35+
</tstamp>
36+
<echo level="info">Checkstyle finished (${checkstyle.sevntu.configLocation}) : ${FINISHED}</echo>
37+
38+
<fail if="checkstyle.failure.property"
39+
message="Checkstyle failed: ${checkstyle.failure.property}"
40+
/>
41+
</target>
42+
</project>

config/ant-phase-verify.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project name="phase-package" default="execute">
4+
<condition property="run">
5+
<or>
6+
<not>
7+
<isset property="checkstyle.ant.skip"/>
8+
</not>
9+
<isfalse value="${checkstyle.ant.skip}"/>
10+
</or>
11+
</condition>
12+
13+
<target name="execute" if="run">
14+
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"/>
15+
16+
<tstamp>
17+
<format property="STARTED" pattern="dd/MM/yyyy hh:mm:ss aa" />
18+
</tstamp>
19+
<echo level="info">Checkstyle started (${checkstyle.configLocation}): ${STARTED}</echo>
20+
21+
<checkstyle config="${checkstyle.configLocation}"
22+
failOnViolation="false"
23+
failureProperty="checkstyle.failure.property"
24+
executeIgnoredModules="true"
25+
>
26+
<fileset dir="src"
27+
includes="**/*"
28+
excludes="test/resources/**/*,it/resources/**/*"/>
29+
<formatter type="plain"/>
30+
<formatter type="xml" toFile="${mvn.project.build.directory}/cs_errors.xml"/>
31+
<property key="checkstyle.cache.file" file="${mvn.project.build.directory}/cachefile"/>
32+
<property key="checkstyle.header.file" value="config/java.header"/>
33+
<property key="checkstyle.regexp.header.file" value="config/java_regexp.header"/>
34+
<property key="checkstyle.importcontrol.file" file="config/import-control.xml"/>
35+
<property key="checkstyle.importcontroltest.file" file="config/import-control-test.xml"/>
36+
<property key="checkstyle.suppressions.file" file="config/suppressions.xml"/>
37+
<property key="checkstyle.suppressions-xpath.file" file="config/suppressions-xpath.xml"/>
38+
</checkstyle>
39+
40+
<tstamp>
41+
<format property="FINISHED" pattern="dd/MM/yyyy hh:mm:ss aa"/>
42+
</tstamp>
43+
<echo level="info">Checkstyle finished (${checkstyle.configLocation}) : ${FINISHED}</echo>
44+
45+
<fail if="checkstyle.failure.property"
46+
message="Checkstyle failed: ${checkstyle.failure.property}"
47+
/>
48+
</target>
49+
</project>

config/checkstyle.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

pom.xml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@
9797
<checkstyle.version>10.3.3</checkstyle.version>
9898
<sonar.version>8.9.0.43852</sonar.version>
9999
<sonar-java.version>7.2.0.26923</sonar-java.version>
100-
<maven.checkstyle.plugin.version>3.1.2</maven.checkstyle.plugin.version>
101100
<maven.sevntu.checkstyle.plugin.version>1.42.0</maven.sevntu.checkstyle.plugin.version>
102101
<!-- it should be a version of checkstyle that is compatible/compiled with sevntu -->
103102
<maven.sevntu.checkstyle.plugin.checkstyle.version>
104103
10.0
105104
</maven.sevntu.checkstyle.plugin.checkstyle.version>
105+
<antrun.plugin.version>3.1.0</antrun.plugin.version>
106+
<checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${maven.sevntu.checkstyle.plugin.checkstyle.version}/config/checkstyle_checks.xml</checkstyle.configLocation>
107+
<checkstyle.sevntu.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle_sevntu_checks.xml</checkstyle.sevntu.configLocation>
106108
<maven.jacoco.plugin.version>0.8.5</maven.jacoco.plugin.version>
107109
<java.version>11</java.version>
108110
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -408,54 +410,52 @@
408410
</plugin>
409411
<plugin>
410412
<groupId>org.apache.maven.plugins</groupId>
411-
<artifactId>maven-checkstyle-plugin</artifactId>
412-
<version>${maven.checkstyle.plugin.version}</version>
413-
<dependencies>
414-
<dependency>
415-
<groupId>com.puppycrawl.tools</groupId>
416-
<artifactId>checkstyle</artifactId>
417-
<version>${maven.sevntu.checkstyle.plugin.checkstyle.version}</version>
418-
</dependency>
419-
<dependency>
420-
<groupId>com.github.sevntu-checkstyle</groupId>
421-
<artifactId>sevntu-checks</artifactId>
422-
<version>${maven.sevntu.checkstyle.plugin.version}</version>
423-
</dependency>
424-
</dependencies>
413+
<artifactId>maven-antrun-plugin</artifactId>
414+
<version>${antrun.plugin.version}</version>
425415
<executions>
426416
<execution>
427-
<id>checkstyle-check</id>
417+
<id>ant-phase-verify</id>
428418
<phase>verify</phase>
429419
<goals>
430-
<goal>check</goal>
420+
<goal>run</goal>
431421
</goals>
432422
<configuration>
433-
<configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${maven.sevntu.checkstyle.plugin.checkstyle.version}/config/checkstyle_checks.xml</configLocation>
434-
<failOnViolation>true</failOnViolation>
435-
<headerLocation>I just need to put here smth to let it not use default - LICENSE.txt</headerLocation>
436-
<propertiesLocation>config/checkstyle.properties</propertiesLocation>
437-
<includeTestResources>false</includeTestResources>
438-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
423+
<target>
424+
<property name="mvn.project.build.directory" value="${project.build.directory}" />
425+
<property name="checkstyle.configLocation" value="${checkstyle.configLocation}" />
426+
<ant antfile="config/ant-phase-verify.xml" />
427+
</target>
439428
</configuration>
440429
</execution>
441430
<execution>
442-
<id>sevntu-checkstyle-check</id>
431+
<id>ant-phase-verify-sevntu</id>
443432
<phase>verify</phase>
444433
<goals>
445-
<goal>check</goal>
434+
<goal>run</goal>
446435
</goals>
447436
<configuration>
448-
<configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle_sevntu_checks.xml</configLocation>
449-
<failOnViolation>true</failOnViolation>
450-
<includeResources>false</includeResources>
451-
<includeTestResources>false</includeTestResources>
452-
<logViolationsToConsole>true</logViolationsToConsole>
453-
<maxAllowedViolations>0</maxAllowedViolations>
454-
<violationSeverity>error</violationSeverity>
455-
<propertyExpansion>project.basedir=${project.basedir}</propertyExpansion>
437+
<target>
438+
<property name="mvn.project.build.directory" value="${project.build.directory}" />
439+
<property name="project.basedir" value="${project.basedir}" />
440+
<property name="checkstyle.sevntu.configLocation"
441+
value="${checkstyle.sevntu.configLocation}" />
442+
<ant antfile="config/ant-phase-verify-sevntu.xml" />
443+
</target>
456444
</configuration>
457445
</execution>
458446
</executions>
447+
<dependencies>
448+
<dependency>
449+
<groupId>com.puppycrawl.tools</groupId>
450+
<artifactId>checkstyle</artifactId>
451+
<version>${maven.sevntu.checkstyle.plugin.checkstyle.version}</version>
452+
</dependency>
453+
<dependency>
454+
<groupId>com.github.sevntu-checkstyle</groupId>
455+
<artifactId>sevntu-checks</artifactId>
456+
<version>${maven.sevntu.checkstyle.plugin.version}</version>
457+
</dependency>
458+
</dependencies>
459459
</plugin>
460460
<plugin>
461461
<groupId>org.apache.maven.plugins</groupId>
@@ -851,7 +851,7 @@
851851
<properties>
852852
<skipTests>true</skipTests>
853853
<skipITs>true</skipITs>
854-
<checkstyle.skip>true</checkstyle.skip>
854+
<checkstyle.ant.skip>true</checkstyle.ant.skip>
855855
<pmd.skip>true</pmd.skip>
856856
<spotbugs.skip>true</spotbugs.skip>
857857
<xml.skip>true</xml.skip>
@@ -865,7 +865,7 @@
865865
<id>sonarqube-validations</id>
866866
<properties>
867867
<skipITs>true</skipITs>
868-
<checkstyle.skip>true</checkstyle.skip>
868+
<checkstyle.ant.skip>true</checkstyle.ant.skip>
869869
<pmd.skip>true</pmd.skip>
870870
<spotbugs.skip>true</spotbugs.skip>
871871
<xml.skip>true</xml.skip>

0 commit comments

Comments
 (0)