I have added 2 Java rules to the existing PMD-Rules. I need to know how to package them.
When I specify the following in the pom.xml and build the projects its throwing an error
It seems, you actually want to create an own module, with your custom rules.
I didn't write up a documentation for this yet, but I would do a similar approach as checkstyle does for multi-module builds.
Create a own project, separate from pmd. You'll add pmd-dependencies, but won't change pmd:
Let's say, you create it in the folder c:\temp\my-custom-pmd-rules
See also maven-pmd-plugin for more information on how to configure the maven plugin.
Alternatively, you can copy the jar file from step 3 into a pmd installation's lib folder. You can zip the complete pmd installation again and can create so a custom binary distribution file with your rules includes.
Hope that helps,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have added 2 Java rules to the existing PMD-Rules. I need to know how to package them.
When I specify the following in the pom.xml and build the projects its throwing an error
Error that I am getting
Missing artifact net.sourceforge.pmd:pmd-core:jar:0.0.1-SNAPSHOT
Missing artifact net.sourceforge.pmd:pmd-test:jar:0.0.1-SNAPSHOT
Can anyone help me with this?
Thanks
It seems, you actually want to create an own module, with your custom rules.
I didn't write up a documentation for this yet, but I would do a similar approach as checkstyle does for multi-module builds.
Create a own project, separate from pmd. You'll add pmd-dependencies, but won't change pmd:
Let's say, you create it in the folder c:\temp\my-custom-pmd-rules
Create a pom.xml file:
Now, place your ruleset xml in the subdirectory
src/main/resources/rulesets/java/
and name the file e.g.custom-rules.xml
. See How to make a ruleset.You can place (in case you are writing Java based rules) your rules in
src/main/java
.Build this new project:
mvn clean install
Now - in your main project, where you want to use the custom rules, configure the maven pmd plugin as follows:
See also maven-pmd-plugin for more information on how to configure the maven plugin.
Alternatively, you can copy the jar file from step 3 into a pmd installation's
lib
folder. You can zip the complete pmd installation again and can create so a custom binary distribution file with your rules includes.Hope that helps,
Andreas
Hi Andreas,
Thank you for the inputs. Created a new project and it works!
When I use this against my code will the other PMD java Rules, included in PMD-5.2.3, also be applied for my code in addition to these two rules
In other simpler words
Will the rules that I added get appended to the Java ruleset or will it override the java ruleset?
Last edit: Karthik Shantaraman 2015-03-23
It is a separate ruleset.
You need to configure, which ruleset(s) to execute.
If you are using maven-pmd-plugin, you can define multiple rulesets: