PMDでカスタムルールの実行
MavenでPMDをカスタムルールで実行するのに、
すごーく苦戦したので、メモっておく。
ルールセットの変更はconfigurationのrulesetsで行う。
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<sourceEncoding>MS932</sourceEncoding>
<targetJdk>1.4</targetJdk>
<rulesets>
<ruleset>src/config/hogehoge.xml</ruleset>
</rulesets>
</configuration>
</plugin>
</plugins>
</reporting>
で、このルールセットに依存するjarがある場合は、
buildのとこでdependencyを追加しておく。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<dependencies>
<dependency>
<groupId>jp.hogehoge.foo.ykhr</groupId>
<artifactId>pmd-rule</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
これで、独自ルールの実行ができる。
たったこんだけ。
なれないとむずかしひ。英語にもツールにも。