maven程序集包括所有子模块依赖项,而无需“已添加,跳过”
所以我有一个带有一堆子模块的父模块,我试图生成一个包含所有模块 jar 及其所有依赖项的 zip 文件。我的程序集描述符看起来像(类似于这个问题):
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<binaries>
<outputDirectory>/</outputDirectory>
<unpack>false</unpack>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
现在,在 maven 2 和 maven 3 中,我看到数百条消息,如下所示:
[INFO] distribution-0.5.1-SNAPSHOT/lib/commons-lang-2.4.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/spring-core-3.0.3.RELEASE.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/commons-logging-1.0.4.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/args4j-2.0.12.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/collections-generic-4.01.jar already added, skipping
我收集这些消息正在发生,因为我的许多子模块共享依赖项(并且某些子模块依赖于其他子模块)并且 maven 正在复制每个子模块的所有传递依赖项都是独立的,因此其中存在大量重复。
有没有办法阻止 Maven 尝试多次复制相同的依赖项?或者至少在尝试隐藏这些“已添加,跳过”消息时?
So I have a parent module with a bunch of sub-modules, and I'm trying to generate a zip file with all of the module jars and all of their dependencies. My assembly descriptor looks like (similar to this question):
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<binaries>
<outputDirectory>/</outputDirectory>
<unpack>false</unpack>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
Now in both maven 2 and maven 3 I'm seeing hundreds of messages that look like:
[INFO] distribution-0.5.1-SNAPSHOT/lib/commons-lang-2.4.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/spring-core-3.0.3.RELEASE.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/commons-logging-1.0.4.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/args4j-2.0.12.jar already added, skipping
[INFO] distribution-0.5.1-SNAPSHOT/lib/collections-generic-4.01.jar already added, skipping
I gather these are happening because many of my sub-modules share dependencies (and some sub-modules depend on other sub-modules) and maven is copying all transitive dependencies for each sub-module independently so there's a ton of repetition in there.
Is there a way I can keep maven from trying to copy the same dependencies multiple times? Or at least hide these "already added, skipping" messages when it tries to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑是否存在任何允许 Maven Assembly 插件静音。这将是一个很好的选择。
另一方面,您可以要求 Maven 抑制所有输出并以安静模式运行。
例如
,但是,您也会丢失所有其他构建时间信息。
I doubt if there exist anything that allows Maven Assembly plug-in to mute. This would be a good option to provide.
On other hand, you can ask Maven to suppress all output and run in quiet mode.
E.g.
But, you will loose all the other build time information as well.