Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: Unpack-Dependencies ... and then forget about them

Tags:

java

maven-2

I have a library A, which depends on the libraries B and C. I unpack the libraries classes of B and C into the jar for library A using the maven-dependency-plugin (see below).

Now, when a library D uses library A, library D can access all the classes of A, B and C. However, I want D only to depend on A but not on the transitive dependencies B and C.

alt text

I know this can be achieved by manually excluding B and C for the dependency A-D but I would like to somehow declare in A that B and C are not to be made known to modules using A.

        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
like image 594
mxro Avatar asked Jun 22 '10 09:06

mxro


People also ask

What is Maven unpack?

org.apache.maven.plugins:maven-dependency-plugin:3.3.0:unpack. Description: Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location.

What does Maven dependency plugin do?

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.

What is Maven classifier?

A Maven artifact classifier is an optional and arbitrary string that gets appended to the generated artifact's name just after its version number. It distinguishes the artifacts built from the same POM but differing in content.


1 Answers

I think you can mark the dependency with the scope "provided" so the dependent project will assume that the jar's are already "provided". Normally they are provided by the container, in your case you "provided" them in dependency A.

In any case modules dependent on A will ignore the dependencies B and C.

like image 173
Peter Tillemans Avatar answered Nov 02 '22 13:11

Peter Tillemans