maven程序集包括所有子模块依赖项,而无需“已添加,跳过”

发布于 2024-10-16 08:44:45 字数 2025 浏览 3 评论 0原文

所以我有一个带有一堆子模块的父模块,我试图生成一个包含所有模块 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撕心裂肺的伤痛 2024-10-23 08:44:45

我怀疑是否存在任何允许 Maven Assembly 插件静音。这将是一个很好的选择。

另一方面,您可以要求 Maven 抑制所有输出并以安静模式运行。

mvn -h
usage: mvn [options] [<goal(s)>] [<phase(s)>]
Options:
  -q,--quiet    Quiet output - only show errors

例如

mvn -q clean package

,但是,您也会丢失所有其他构建时间信息。

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.

mvn -h
usage: mvn [options] [<goal(s)>] [<phase(s)>]
Options:
  -q,--quiet    Quiet output - only show errors

E.g.

mvn -q clean package

But, you will loose all the other build time information as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文