Search code examples
mavenmaven-assembly-plugin

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:

  • I am using maven 3.0.2 but maven 3.0.3 exhibits the same behavior.
  • My pom dependency for the jar uses a 'jar-with-dependencies' classifier.

Solution

  • 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.