javamavenjarmaven-assembly-plugin

How to exclude dependencies from maven assembly plugin : jar-with-dependencies?


Maven's assembly plugin enables the creation of a big jar including all dependencies with descriptorRef jar-with-dependencies.

How can one exclude some of these dependencies? It seems like it does not have such a configuration? Is there another solution?


Solution

  • This example indicates one way to do this:

     <dependencySets>
        <dependencySet>
          ....
          <excludes>
            <exclude>commons-lang:commons-lang</exclude>
            <exclude>log4j:log4j</exclude>
          </excludes>
        </dependencySet>
        ....
      </dependencySets>
    

    Essentially we would use the excludes option available in dependencySet.

    See also: https://maven.apache.org/plugins/maven-assembly-plugin/assembly-component.html