I am trying to use the same pmd configuration for all my submodules. I am looking for the best way to achieve this.
I thought I could place it in the parent project, for example, I did it for the checkstyle plugin
Parent pom.xml
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <configLocation>/src/main/config/checkstyle.xml</configLocation> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>2.7.1</version> <configuration> <rulesets> <ruleset>pmd.xml</ruleset> </rulesets> <linkXref>true</linkXref> <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding> <targetJdk>${maven.compiler.target}</targetJdk> </configuration> </plugin> </plugins> </build>
The structure of several modules
Here is my structure
parent |-- src | `-- main | `-- resources | |-- pmd.xml | `-- checkstyle.xml |-- pom.xml |-- model | `-- pom.xml `-- webapp `-- pom.xml
Error
With this configuration, I get only the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:2.7.1:pmd (default-cli) on project model: An error has occurred in PMD Report report generation. Could not find resource 'pmd.xml'. -> [Help 1]
Solution 1
I tried this solution, which works for me because I have only one level on the submodules: But in the near future I may have more levels, so I'm not sure if the method $ {Base_Folder_name} /../ SRC / main / resources / pmd.xml
Decision 2
Without writing the whole solution, I can use the assembly for the zip configuration and use it in all my submodules as a dependency. It will work at any level, but it is too difficult!
Here is a link that explains this: How to incorporate resources from war into another maven project
So I'm looking for a Maven trick, but I don't know what and how! Every tip / tip is appreciated.
source share