开发者

Maven assembly dependency set with include doesn't pick up transitive dependencies

开发者 https://www.devze.com 2023-03-06 10:35 出处:网络
I\'m having a spot of bother with the Maven assembly goal. I have a project which has a number of dependencies each of which may have their own transitive dependencies. If I run mvn dependency:tree th

I'm having a spot of bother with the Maven assembly goal. I have a project which has a number of dependencies each of which may have their own transitive dependencies. If I run mvn dependency:tree than I can see all the dependencies including transitive are satisfied.

This is not the case when I run the assembly goal.What I would like is when I add an dependency to be included, then all of its transitive dependencies are also included. In the following example I have three dependencies I would like to be included. So when the assembly is made I expected to have those dependencies and any transitive dependencies for those dependencies as well.

<assembly>
<baseDirectory>${artifactId}/${artifactId}-${version}</baseDirectory>
<formats>
    <format>zip</format>
</formats>

<fileSets>
</fileSets>

<dependencySets>
    <dependencySet>
        <unpack>false</unpack>
        <scope>runtime</scope>
        <outputDirectory>/lib
        </outputDirectory>
        <includes>
            <include>com.acme.core:library-1</include>
            <include>com.acme.core:library-2</include>
            <include>com.acme.core:library-2</include>
        </includes>
    </dependencySet>
</dependencySets>

But if you open the the zip file you'll only find those three dependencies present which means at runtime the application is not fit for purpose due to missing libraries. I find this totally unintuitive as it goes against the behaviour one would expect from the POM.

Has anyone encountered this problem and is there 开发者_如何学JAVAa solution?


The "includes" and "excludes" apply to the transitive dependencies as well. Try adding the following configuration to your dependencySet:

<useTransitiveFiltering>true</useTransitiveFiltering>

http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#dependencySet

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号