Search code examples
mavenmaven-dependency-plugin

How can I exclude artifacts by packaging in maven-dependency-plugin:copy-dependencies


I'm working in a complex tomcat configuration where I'm using third party proprietary service that is distributed as WARs. In the servlet container I have 10 WARs deployed where only one is coded by us.

We are using maven to manage the project.

I'm declaring the third party WAR files in the POM with provided scope.

My issue comes when I try to use maven to deploy the system in a local testing server. I'm using maven-dependency-plugin:copy-dependencies goal to copy the right artifacts in the right directories in the local serving tester.

I must copy JAR files in one directory and WAR files to a different directory. But maven is not differentiating the artifacts by packaging. So I end having the JARs mixed with the WARs in the destination directory. While I need to have two executions, one for WARs and one for JARs going to the right directory.

I have only being able to use a copy goal specifying every artifact to copy, but this is difficult to maintain if any developer adds a new dependency, the dependency must also be added to the right copy goal.

I will like to be able to use copy-dependencies goal but being able to indicate that I only want to copy a specific packaging.

Any idea on how I can manage to do that?

Thanks!


Solution

  • You can use -DexcludeTypes=war

    https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html#excludeTypes