Riccardo T.
Riccardo T.

Reputation: 8937

Excluding shared dependencies from the assembly of one project

In my xml configuration for the maven-assembly-plugin of project B, all dependencies of the project are exported to the lib/ subfolder.

<dependencySet>
    <useProjectArtifact>false</useProjectArtifact>
    <outputDirectory>lib</outputDirectory>
    <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}
    </outputFileNameMapping>
    <scope>runtime</scope>
</dependencySet>

However, project B is a plugin for project A, therefore many dependencies are shared and will be already present in project A's assembly.

How do I exclude from B's assembly all of these shared dependencies, please? I saw that there is an <excludes> tag, but even if it supports wildcards I'd have to keep the list up to date by hand. Can I exploit the pom files of the two projects somehow instead?

Upvotes: 0

Views: 102

Answers (1)

Roberto Benazzato
Roberto Benazzato

Reputation: 467

You can solve this issue using scope. in your project B the scope of the common dependency have to be set as provided. That make your dependency (and sub dependency) used only in compile phase. In your pom the dependency shoud looks like:

       <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.2.2</version>
            <scope>provided</scope>
        </dependency>

hope this help

Upvotes: 1

Related Questions