I want to exclude the parent pom (where the following code is located) from being copied when the package:copy
goal is executed and I can't find examples or figure it out on my own:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
<classifier>shaded</classifier>
<destFileName>${project.name}.${project.packaging}</destFileName>
<excludes>*.pom</excludes> <!-- not working -->
</artifactItem>
</artifactItems>
<outputDirectory>${rootdir}/target/modules</outputDirectory>
<silent>true</silent>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
Regardless of the <excludes>
setting inside artifactItem
, it still includes my parent projects NiftyParent.pom
. I want to exclude the file from being copies to the ${rootdir}/target/modules
directory.
Incase anyone asks, the ${rootdir}
property just points to the parent project directory without hardcoding relative/absolute paths (for sake of argument its ~/Workspace/Nifty
.
You could use the
skip
configuration element of the plugin together with a Mavenproperty
defined in the parent and its modules in order to skip the execution.In your parent pom you can configure it as following:
Note the additional property and the
skip
element configuration.Then, in each module you could configure simply the following:
As such, we are actually switching it on/off based on parent/module location. Additional advantage of this approach is that you would also be able to skip it for some modules (if required) and be able to switch it on/off for all (in your case off) from command line (overriding defined properties values) via for instance:
This approach is not using the plugin configuration, but it's often used whenever a skip is required in many other plugins and cases.