2

I'm using the maven-assembly-plugin to create a jar file that contains all of the dependencies needed to run my app. The configuration for the assembly uses a descriptorRef that points to my custom assembly.

When I look in the maven repository, I see the jar, the pom, and the jar-with-dependencies that is the point of the exercise.

When I pull jar-with-dependencies using maven-dependency-plugin:2.4:get, in addition to copying jar-with-dependencies to dest, it also pulls down the transitive dependencies to my local maven repository.

The behavior I expected to see, since jar-with-dependencies has everything already embedded in it, is that only that jar file would be retrieved. In other words, I expected the behavior I see when I call dependency:get with -Dtransitive=false.

Does the fact that I need the transitive flag indicate that something is incorrect or missing in, presumably either in the pom or in the assembly descriptor? Should I be doing something different in the pom or the assembly so that the jar-with-dependencies has an empty list of dependencies?

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
  • I'm struggling with this as well. Is there nobody out there that can give a straight answer yes/no: Is it possible for an artifact with a different classifier within the same POM to carry different dependencies from the main artifact? – clacke Aug 02 '13 at 11:04

1 Answers1

1

The maven-dependency-plugin does not (and cannot) know, that your jar-with-dependencies does already contain all dependencies. It just looks at the POM file of your artifact and downloads the JAR and its dependencies, unless you specify -Dtransitive=false.

That's exactly what the documentation of the get goal says:

Downloads a single artifact transitively from the specified remote repositories.

Update:

There is nothing incorrect or missing with your setup but it's not possible to make maven aware that your JAR does already contain all dependencies. From Maven's point of view, the jar-with-dependencies is like any other JAR file in your maven repository. Maven does not have any knowledge about the contents of your JAR file.

Stefan Ferstl
  • 5,135
  • 3
  • 33
  • 41