I'm developing a Maven parent project (not aggregator!) project which contains Maven plugins and other things which I repeat in almost every project and which I want to use in projects through the
<parent>
<groupId>richtercloud</groupId>
<artifactId>maven-parent</artifactId>
<version>1</version>
<relativePath></relativePath>
</parent>
idiom. relativePath
is empty because resolution ought to occur throught the Maven cache as you probably know if you feel ready to answer this question.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>check_style</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</execution>
</executions>
<configuration>
<configLocation>check_style.xml</configLocation>
</configuration>
</plugin>
and thus maven-checkstyle-plugin
is used in all projects containing parent
directive above.
The thing is that
- either the
plugin
section above is put intoreporting
in the parent (without theexecutions
because that'd be invalid), then theconfiguration
is ignored and consequently the default XML being used - or the
plugin
section is put intobuild
in the parent POM, then the parent project doesn't compile because it doesn't search the file specified inconfigLocation
in classpath (which it should afaik) and thus fails due toFailed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (check_style) on project maven-parent: Failed during checkstyle execution: Unable to find configuration file at location: check_style.xml: Could not find resource 'check_style.xml'. -> [Help 1]
. Prependingsrc/main/resources
helps to compile the parent, but causes failure in all other project because they resolveconfigLocation
tosrc/main/resources/src/main/resources/check_style.xml
which is correct. A bug?
This is not answered by Maven inherit parent module resources because the question doesn't specify how it references the parent
project, i.e. with which relativePath
.
I'm using Maven 3.3.9.