Chcę Maven-PMD-plugin do włączenia zestawów reguł, które mogę określić i wykluczyć niektóre zasady (w szczególności UselessParentheses)Nie można użyć niestandardowego zestawu reguł w maven-PMD-plugin 5.0.2
podobnie jak opisane w documentation, i umieszcza się następujące w pmd.xml który jest dominującym dla wszystkich modułów:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.0</version>
<configuration>
<rulesets>
<ruleset>/home/ubuntu/ruleset.xml</ruleset>
</rulesets>
</configuration>
</plugin>
</plugins>
</reporting>
i przygotowane własny zestaw reguł, jak z tego:
<!-- We'll use the entire rulesets -->
<rule ref="rulesets/java/basic.xml"/>
<rule ref="rulesets/java/imports.xml"/>
<rule ref="rulesets/java/codesize.xml"/>
<rule ref="rulesets/java/design.xml"/>
<rule ref="rulesets/java/strings.xml"/>
<rule ref="rulesets/java/unusedcode.xml"/>
<!-- We want everything from this except some -->
<rule ref="rulesets/java/unnecessary.xml">
<exclude name="UselessParentheses"/>
</rule>
jako głównej części.
Mimo to uruchamiam mvn clean jxr:jxr pmd:check
Mam "UselessParentheses" w raportach. Ponadto uruchomienie go z -X
pokazuje
[DEBUG] Preparing ruleset: java-basic
[DEBUG] Before: java-basic After: java-basic.xml
[DEBUG] The resource 'rulesets/java/basic.xml' was found as jar:file:/home/ubuntu/.m2/repository/net/sourceforge/pmd/pmd/5.0.2/pmd-5.0.2.jar!/rulesets/java/basic.xml.
[DEBUG] Preparing ruleset: java-unusedcode
[DEBUG] Before: java-unusedcode After: java-unusedcode.xml
[DEBUG] The resource 'rulesets/java/unusedcode.xml' was found as jar:file:/home/ubuntu/.m2/repository/net/sourceforge/pmd/pmd/5.0.2/pmd-5.0.2.jar!/rulesets/java/unusedcode.xml.
[DEBUG] Preparing ruleset: java-imports
[DEBUG] Before: java-imports After: java-imports.xml
[DEBUG] The resource 'rulesets/java/imports.xml' was found as jar:file:/home/ubuntu/.m2/repository/net/sourceforge/pmd/pmd/5.0.2/pmd-5.0.2.jar!/rulesets/java/imports.xml.
Tak wygląda PMD zignorował mój własny zestaw reguł.
Chcę, aby niestandardowy zestaw reguł zadziałał. Co ja robię źle?
Dziękuję. To działa. Po prostu zrobiłem wszystko, co powiedzieli w [docs] (http://maven.apache.org/plugins/maven-pmd-plugin/examples/usingRuleSets.html) i nie otrzymałem wyników. Nie było ani słowa o umieszczeniu konfiguracji w sekcji "kompilacja". –
Ale jeśli spojrzysz na http://maven.apache.org/plugins/maven-pmd-plugin/usage.html, zobaczysz wszystkie miejsca, w których możesz umieścić deklarację wtyczki ... – gavenkoa
Podobnie jak wiele innych wtyczek, dokumentacja jest brakująca w szczegółach. Uważam to za kłopotliwe, biorąc pod uwagę to, o czym marzą wszyscy maven. –