我对Maven的组装目标有一点困扰。我有一个项目,它有许多依赖项,每个依赖项都可能有自己的传递依赖项。如果我运行mvn dependency:tree,那么我可以看到所有的依赖关系都得到了满足,包括传递性。
这不是当我运行程序集goal.What时的情况,我希望当我添加一个要包含的依赖项时,它的所有传递依赖项也会包含在内。在下面的示例中,我希望包含三个依赖项。因此,当组装完成时,我希望有这些依赖关系,以及这些依赖关系的任何传递依赖关系。
<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>
但是,如果您打开zip文件,您将只发现存在这三个依赖项,这意味着在运行时,由于缺少库,应用程序不适合使用。我发现这完全不符合直觉,因为它违背了人们对POM的期望。
有没有人遇到过这个问题,有没有解决方案?
发布于 2011-08-17 02:26:30
“包含”和“排除”也适用于传递依赖关系。尝试将以下配置添加到您的dependencySet
<useTransitiveFiltering>true</useTransitiveFiltering>http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#dependencySet
https://stackoverflow.com/questions/6018174
复制相似问题