Excluding Dependency with Maven Assembly Plugin
I have an assembly project with two direct dependencies, a war and an jar. In the assembly descriptor, I am trying to place the war in one folder and the jar in another. As such, I am using the following dependencySet snippet:
<dependencySets>
<dependencySet>
<outputDirectory>webapps</outputDirectory>
<includes>
<include>*:war</include>
</includes>
<directoryMode>750</directoryMode>
<fileMode>660</fileMode>
</dependencySet>
<dependencySet>
<outputDirectory>bin</outputDirectory>
<includes>
<include>mygroup:my-jar-artifact</include>
</includes>
<directoryMode>750</directoryMode>
<fileMode>660</fileMode>
</dependencySet>
</dependencySets>
However, when I execute "mvn assembly:single", it always ends up placing the jar in the webapps directory. I have tried every possible way to force it to exclude the jar (including adding excludes tags, etc). I know I could do a workaround by using the by using the maven dependency plugin to copy the jar to a folder and then use the assembly descriptor to copy the flat file over. However, I really feel like I ought to be able to use dependency sets to do this. Any ideas?
Additional information:
Could it be that it is copying transitive dependencies of the WAR?
Try using either
<useTransitiveDependencies>false</useTransitiveDependencies>
or
<useTransitiveFiltering>true</useTransitiveFiltering>
in the dependencySet of the WAR.
Assembly Descriptor documentation
If useTransitiveDependencies
is turned off (it is on by default), the transitive dependencies of the WAR should not be copied.
If useTransitiveFiltering
is turned on (it is off by default), the filters you define will apply to the transitive dependencies of the WAR, and since this is including *:war
should not include any of the dependency JARs when copying.
Another possibility is the syntax *:war
is incorrect.
Can you try specifying the groupId:artifactId explicitly in the <include>
, the same way that you have done for the jar
artifact?
<includes>
<include>mygroup:my-war-artifact</include>
</includes>
I figured it out. I was going to look at the source code for the assembly plugin to figure out the problem. In doing so, I noticed that I was using assembly 2.2-beta-1. Upgrading to 2.2 fixed the issue entirely. Lesson learned that I should always check the version of the plugin next time.
链接地址: http://www.djcxy.com/p/29614.html