Skip to content

Commit a22d20d

Browse files
authored
Merge pull request #74 from xdev-software/pmd
Introduce PMD
2 parents f697749 + 11c6f7e commit a22d20d

File tree

4 files changed

+145
-36
lines changed

4 files changed

+145
-36
lines changed

.github/workflows/check-build.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
7171
if-no-files-found: error
7272

73-
code-style:
73+
checkstyle:
7474
runs-on: ubuntu-latest
7575
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
7676

@@ -91,3 +91,40 @@ jobs:
9191

9292
- name: Run Checkstyle
9393
run: ./mvnw -B checkstyle:check -P checkstyle -T2C
94+
95+
pmd:
96+
runs-on: ubuntu-latest
97+
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
98+
99+
strategy:
100+
matrix:
101+
java: [17]
102+
distribution: [temurin]
103+
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- name: Set up JDK
108+
uses: actions/setup-java@v4
109+
with:
110+
distribution: ${{ matrix.distribution }}
111+
java-version: ${{ matrix.java }}
112+
cache: 'maven'
113+
114+
- name: Run PMD
115+
run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C
116+
117+
- name: Run CPD (Copy Paste Detector)
118+
run: ./mvnw -B pmd:aggregate-cpd pmd:cpd-check -P pmd -DskipTests -T2C
119+
120+
- name: Upload report
121+
if: always()
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: pmd-report
125+
if-no-files-found: ignore
126+
path: |
127+
target/site/*.html
128+
target/site/css/**
129+
target/site/images/logos/maven-feather.png
130+
target/site/images/external.png

pom.xml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<module>template-placeholder-demo</module>
2020
</modules>
2121

22+
<properties>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
25+
</properties>
26+
2227
<licenses>
2328
<license>
2429
<name>Apache License, Version 2.0</name>
@@ -29,20 +34,74 @@
2934

3035
<profiles>
3136
<profile>
32-
<!-- Disable checkstyle in root module as there is nothing to check -->
3337
<id>checkstyle</id>
3438
<build>
3539
<plugins>
3640
<plugin>
3741
<groupId>org.apache.maven.plugins</groupId>
3842
<artifactId>maven-checkstyle-plugin</artifactId>
3943
<version>3.4.0</version>
44+
<dependencies>
45+
<dependency>
46+
<groupId>com.puppycrawl.tools</groupId>
47+
<artifactId>checkstyle</artifactId>
48+
<version>10.17.0</version>
49+
</dependency>
50+
</dependencies>
51+
<configuration>
52+
<configLocation>.config/checkstyle/checkstyle.xml</configLocation>
53+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
54+
</configuration>
55+
<executions>
56+
<execution>
57+
<goals>
58+
<goal>check</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
</profile>
66+
<profile>
67+
<id>pmd</id>
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-pmd-plugin</artifactId>
73+
<version>3.23.0</version>
4074
<configuration>
41-
<skip>true</skip>
75+
<includeTests>true</includeTests>
76+
<rulesets>
77+
<ruleset>.config/pmd/ruleset.xml</ruleset>
78+
</rulesets>
4279
</configuration>
80+
<dependencies>
81+
<dependency>
82+
<groupId>net.sourceforge.pmd</groupId>
83+
<artifactId>pmd-core</artifactId>
84+
<version>7.2.0</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>net.sourceforge.pmd</groupId>
88+
<artifactId>pmd-java</artifactId>
89+
<version>7.2.0</version>
90+
</dependency>
91+
</dependencies>
4392
</plugin>
4493
</plugins>
4594
</build>
95+
<reporting>
96+
<plugins>
97+
<!-- Required for reporting -->
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-jxr-plugin</artifactId>
101+
<version>3.4.0</version>
102+
</plugin>
103+
</plugins>
104+
</reporting>
46105
</profile>
47106
</profiles>
48107
</project>

template-placeholder-demo/pom.xml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>software.xdev</groupId>
7+
<parent>
8+
<groupId>software.xdev</groupId>
9+
<artifactId>template-placeholder-root</artifactId>
10+
<version>1.0.0-SNAPSHOT</version>
11+
</parent>
12+
813
<artifactId>template-placeholder-demo</artifactId>
914
<version>1.0.0-SNAPSHOT</version>
1015
<packaging>jar</packaging>
@@ -77,36 +82,4 @@
7782
</plugin>
7883
</plugins>
7984
</build>
80-
<profiles>
81-
<profile>
82-
<id>checkstyle</id>
83-
<build>
84-
<plugins>
85-
<plugin>
86-
<groupId>org.apache.maven.plugins</groupId>
87-
<artifactId>maven-checkstyle-plugin</artifactId>
88-
<version>3.4.0</version>
89-
<dependencies>
90-
<dependency>
91-
<groupId>com.puppycrawl.tools</groupId>
92-
<artifactId>checkstyle</artifactId>
93-
<version>10.17.0</version>
94-
</dependency>
95-
</dependencies>
96-
<configuration>
97-
<configLocation>../.config/checkstyle/checkstyle.xml</configLocation>
98-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
99-
</configuration>
100-
<executions>
101-
<execution>
102-
<goals>
103-
<goal>check</goal>
104-
</goals>
105-
</execution>
106-
</executions>
107-
</plugin>
108-
</plugins>
109-
</build>
110-
</profile>
111-
</profiles>
11285
</project>

template-placeholder/pom.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,45 @@
265265
</plugins>
266266
</build>
267267
</profile>
268+
<profile>
269+
<id>pmd</id>
270+
<build>
271+
<plugins>
272+
<plugin>
273+
<groupId>org.apache.maven.plugins</groupId>
274+
<artifactId>maven-pmd-plugin</artifactId>
275+
<version>3.23.0</version>
276+
<configuration>
277+
<includeTests>true</includeTests>
278+
<rulesets>
279+
<ruleset>../.config/pmd/ruleset.xml</ruleset>
280+
</rulesets>
281+
</configuration>
282+
<dependencies>
283+
<dependency>
284+
<groupId>net.sourceforge.pmd</groupId>
285+
<artifactId>pmd-core</artifactId>
286+
<version>7.2.0</version>
287+
</dependency>
288+
<dependency>
289+
<groupId>net.sourceforge.pmd</groupId>
290+
<artifactId>pmd-java</artifactId>
291+
<version>7.2.0</version>
292+
</dependency>
293+
</dependencies>
294+
</plugin>
295+
</plugins>
296+
</build>
297+
<reporting>
298+
<plugins>
299+
<!-- Required for reporting -->
300+
<plugin>
301+
<groupId>org.apache.maven.plugins</groupId>
302+
<artifactId>maven-jxr-plugin</artifactId>
303+
<version>3.4.0</version>
304+
</plugin>
305+
</plugins>
306+
</reporting>
307+
</profile>
268308
</profiles>
269309
</project>

0 commit comments

Comments
 (0)