2

I want to include only a specific jar and its dependencies using maven-assembly-plugin something like below. My expectation is to copy apache-cxf-2.7.11 and all its dependency jars into "lib/apache-cxf-2.7.11"

<dependencySet>
            <outputDirectory>lib/apache-cxf-2.7.11</outputDirectory>
            <useTransitiveDependencies>true</useTransitiveDependencies>
            <includes>
                <include>org.apache.cxf:apache-cxf</include>
            </includes>
</dependencySet>
Shankar Anand
  • 223
  • 1
  • 3
  • 11

2 Answers2

1

It worked now. I used true and it pulled all the dependencies

Shankar Anand
  • 223
  • 1
  • 3
  • 11
0

Having banged my head against that very issue for a couple years now, I am posting here the explanation of why the above will not work in the general case in the hope this can help some people...

The problem will arise if the module hosting the assembly execution and the artifact for which you are trying to extract dependencies have common dependencies... for example:

module A:
   dep. lib-a1
   dep. lib-common

module B:
    dep. lib-common
    dep. module A
    main/assembly/moduleA-with-dependencies: <??> 

I am afraid there is no assembly plugin configuration that would allow you, while executing in module B, to include all module A dependencies: that is because lib-common is being seen by maven as a direct dependency of module B and never makes it into the module A dependency set.

If someone know how to select lib-a1 and lib-common in the above situation (with no harcoding of course...) I'd really like to hear about it. But the fact that mvn dependency:tree in module B doesn't show lib-common as a dependency of module A leaves me little hope...

Franck

franck102
  • 221
  • 4
  • 14