gpt4 book ai didi

maven-2 - Maven Assembly 插件 - 多模块项目 - 源和 javadoc 未添加到 zip 文件

转载 作者:行者123 更新时间:2023-12-03 22:14:10 24 4
gpt4 key购买 nike

我有多个模块项目并使用 Maven 的程序集插件来压缩项目的工件。

Proj
+Module A
pom.xml
+Module B
pom.xml
pom.xml

当我构建主模块时,它会产生以下东西

Proj
+Module A
target\A.jar
target\A-source.jar
target\A-javadoc.jar
+Module B
target\B.jar
target\B-source.jar
target\B-javadoc.jar

1) 我在 ModuleB pom 文件下添加了汇编插件,我在汇编描述 rune 件中使用了 ModuleSet

<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>groupA:A:jar</include>
<include>groupA:A:javadoc</include>
<include>groupA:A:source</include>
</includes>
<binaries>
<outputDirectory>moduleA</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>

<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>groupB:B:jar</include>
<include>groupB:B:javadoc</include>
<include>groupB:B:source</include>
</includes>
<binaries>
<outputDirectory>moduleB</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>

但我在 zip 文件下只得到 A.jar 和 B.Jar。我没有在 zip 文件中获取 javadoc 和源代码。它是从 m2 repo 下载它吗,我怀疑它是否这样做,因为源代码和 java doc 不会在 maven reporee 工件中。如何将所有三个工件添加到一个 zip 文件中?

2) 我想在我的父 pom 而不是 ModuleB 的 pom 中添加程序集插件,但是如果我这样做,我会得到一个异常“请确保在程序集生成之前运行包阶段”。谷歌搜索后,我发现很少有人建议将程序集添加为模块。有没有其他方法可以解决这个问题?

最佳答案

我用dependecySet来解决这个问题,我们可以使用通配符来添加所有的二进制文件。

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<includes>
<include>groupA:*:*:*</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>

这将添加项目的所有二进制工件。需要注意的另一件事是程序集描述符中使用的 id。它应该是二进制工件的 bin。如果有人遇到类似问题,请在此处发帖,这可能会有所帮助。

关于maven-2 - Maven Assembly 插件 - 多模块项目 - 源和 javadoc 未添加到 zip 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10609836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com