Skip to content

Commit 22c127d

Browse files
authored
Merge pull request #19 from ligangty/master
Enable PMD check for code convention in Commonjava
2 parents 7bb7924 + 5554ce4 commit 22c127d

File tree

2 files changed

+71
-8
lines changed

2 files changed

+71
-8
lines changed

pmd-ruleset.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0"?>
2+
3+
<ruleset name="Custom ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
6+
<description>
7+
Commonjava PMD ruleset
8+
</description>
9+
10+
<rule ref="rulesets/java/basic.xml"/>
11+
<rule ref="rulesets/java/braces.xml"/>
12+
<rule ref="rulesets/java/clone.xml"/>
13+
<rule ref="rulesets/java/codesize.xml"/>
14+
<rule ref="rulesets/java/coupling"/>
15+
<rule ref="rulesets/java/comments"/>
16+
<rule ref="rulesets/java/design"/>
17+
<rule ref="rulesets/java/empty.xml"/>
18+
<rule ref="rulesets/java/finalizers.xml"/>
19+
<rule ref="rulesets/java/imports.xml">
20+
<exclude name="TooManyStaticImports"/>
21+
</rule>
22+
<rule ref="rulesets/java/javabeans.xml"/>
23+
<rule ref="rulesets/java/junit.xml"/>
24+
<rule ref="rulesets/java/naming.xml"/>
25+
<rule ref="rulesets/java/optimizations.xml"/>
26+
<rule ref="rulesets/java/strictexception.xml">
27+
<exclude name="AvoidCatchingThrowable"/>
28+
</rule>
29+
<rule ref="rulesets/java/strings.xml"/>
30+
<rule ref="rulesets/java/sunsecure.xml"/>
31+
<rule ref="rulesets/java/unnecessary.xml"/>
32+
<rule ref="rulesets/java/unusedcode.xml"/>
33+
34+
<!--
35+
<rule ref="rulesets/java/j2ee.xml"/>
36+
<rule ref="rulesets/java/logging-jakarta-commons.xml"/>
37+
<rule ref="rulesets/java/logging-java.xml"/>
38+
-->
39+
40+
</ruleset>

pom.xml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,35 @@
2424
<packaging>pom</packaging>
2525

2626
<name>CommonJava Top-Level Parent POM</name>
27-
27+
2828
<url>https://github.com/Commonjava/commonjava</url>
2929

3030
<description>CommonJava top-level parent POM.</description>
3131
<inceptionYear>2012</inceptionYear>
32-
32+
3333
<licenses>
3434
<license>
3535
<name>Apache License, Version 2.0</name>
3636
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
3737
<distribution>repo</distribution>
3838
</license>
3939
</licenses>
40-
40+
4141
<developers>
4242
<developer>
4343
<id>jdcasey</id>
4444
<email>jdcasey@commonjava.org</email>
4545
<name>John Casey</name>
4646
</developer>
4747
</developers>
48-
48+
4949
<scm>
5050
<connection>scm:git:https://github.com/Commonjava/commonjava.git</connection>
5151
<developerConnection>scm:git:git@github.com:Commonjava/commonjava.git</developerConnection>
5252
<url>http://github.com/Commonjava/commonjava</url>
5353
<tag>HEAD</tag>
5454
</scm>
55-
55+
5656
<properties>
5757
<javaVersion>1.7</javaVersion>
5858
<javaTestVersion>${javaVersion}</javaTestVersion>
@@ -76,6 +76,7 @@
7676
<version.plugin.install>2.4</version.plugin.install>
7777
<version.plugin.resources>2.6</version.plugin.resources>
7878
<version.plugin.site>3.3</version.plugin.site>
79+
<version.plugin.pmd>3.6</version.plugin.pmd>
7980

8081
<skipIllegalTransitiveEnforcement>false</skipIllegalTransitiveEnforcement>
8182
<enforceManagedDeps>true</enforceManagedDeps>
@@ -291,7 +292,7 @@
291292
</mapping>
292293
</configuration>
293294
</plugin>
294-
295+
295296
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
296297
<plugin>
297298
<groupId>org.eclipse.m2e</groupId>
@@ -380,6 +381,24 @@
380381
<artifactId>maven-site-plugin</artifactId>
381382
<version>${version.plugin.site}</version>
382383
</plugin>
384+
<plugin>
385+
<groupId>org.apache.maven.plugins</groupId>
386+
<artifactId>maven-pmd-plugin</artifactId>
387+
<version>${version.plugin.pmd}</version>
388+
<configuration>
389+
<targetJdk>${javaVersion}</targetJdk>
390+
<ruleset>pmd-ruleset.xml</ruleset>
391+
</configuration>
392+
<executions>
393+
<execution>
394+
<phase>process-sources</phase>
395+
<goals>
396+
<goal>check</goal>
397+
<goal>pmd</goal>
398+
</goals>
399+
</execution>
400+
</executions>
401+
</plugin>
383402
</plugins>
384403
</pluginManagement>
385404
<plugins>
@@ -388,10 +407,10 @@
388407
</plugin>
389408
</plugins>
390409
</build>
391-
410+
392411
<profiles>
393412
<profile>
394-
<id>formatting</id>
413+
<id>cq</id>
395414
<build>
396415
<plugins>
397416
<plugin>
@@ -406,6 +425,10 @@
406425
</execution>
407426
</executions>
408427
</plugin>
428+
<plugin>
429+
<groupId>org.apache.maven.plugins</groupId>
430+
<artifactId>maven-pmd-plugin</artifactId>
431+
</plugin>
409432
</plugins>
410433
</build>
411434
</profile>

0 commit comments

Comments
 (0)