gpt4 book ai didi

maven - 在多模块项目中生成聚合 javadoc 时如何避免重复 fork

转载 作者:行者123 更新时间:2023-12-04 08:43:34 26 4
gpt4 key购买 nike

我正在尝试配置一个 Maven 多模块项目以通过程序集插件生成分发 zip,其中应包括项目中所有子模块的聚合 javadoc。

项目结构是(简化,实际上有大约 20 个模块):

Project X Core
+- pom.xml (1)
+- module-A
| +- pom.xml (2)
+-module-B
| +- pom.xml (3)
+-assembly
+- pom.xml (4)

在哪里 assembly是生成分发 zip 的子模块。根 pom 将所有子模块列为模块,每个子模块的 pom 依次将根 pom 作为其父级。程序集插件绑定(bind)到 package阶段。所有这一切都很好。

当我尝试创建聚合的 javadoc(不是 javadoc jar,而是带有 html 的目录)以包含在程序集中时,就会出现问题。为此,我在根 pom 中将 maven-javadoc-plugin 配置为构建插件,如下所示:
   <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>1.6</source>
<encoding>utf8</encoding>
<quiet>true</quiet>
<links>
<link>http://docs.oracle.com/javase/6/docs/api/</link>
</links>
</configuration>
<executions>
<execution>
<id>create-javadoc</id>
<phase>package</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>

此外,我在程序集子模块中配置了我的程序集描述符,以包含一个带有 javadocs 的文件集,从其父项目的目标目录中挑选:
    <fileSet>
<directory>../target/site/apidocs</directory>
<outputDirectory>docs/apidocs</outputDirectory>
</fileSet>

我在使用此设置时遇到的问题是:运行 mvn package 时看到以下输出:
[INFO] Reactor Build Order:
[INFO]
[INFO] Project X Core
[INFO] Project X: module A
[INFO] Project X: module B
[INFO] Project X: assembly
[INFO] ------------------------------------------------------------------------
[INFO] Building Project X Core 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-core ---
[INFO]
[INFO] --- animal-sniffer-maven-plugin:1.13:check (default) @ projectX-core ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java16:1.0
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.1:aggregate (create-javadoc) > generate-sources @ projectX-core >>>
[INFO]
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking Project X Core 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-core ---
[INFO]
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking Project X: module A 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modA ---
[INFO]
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking Project X: module B 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modB ---
Downloading: https://example.org/repositories/snapshots/org/example/project/projectX-modB/1.0.0-SNAPSHOT/modB-1.0.0-20141121.022310-7.jar
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking Project X: Assembly 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Downloading: https://example.org/repositories/snapshots/org/example/project/projectX-modC/1.0.0-SNAPSHOT/maven-metadata.xml
2/2 KB
(snip for brevity)
[INFO] ------------------------------------------------------------------------
[INFO] Building Project X: module A 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modA ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ projectX-modA ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jeen/Projects/projectX/modA/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ projectX-modA ---
[INFO] Compiling 52 source files to /Users/jeen/Projects/projectX/modA/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ projectX-modA ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jeen/Projects/projectX/modA/util/src/test/resources
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ projectX-modA ---
[INFO] Building jar: /Users/jeen/Projects/projectX/modA/target/modA-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.1:aggregate (create-javadoc) > generate-sources @ projectX-modA >>>
[INFO]
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking Project X Core 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-core ---
[INFO]
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking Project X Module A 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modA ---
[INFO]
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] Forking ProjectX Module B 1.0.0-SNAPSHOT
[INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.....

这只是一个片段,但是这些“ fork ”消息对于每个子模块重复了很多次(实际上,每个模块大约重复了 60 次)。这让我很担心:看起来好像有很多重复的工作正在进行。让我担心的第二件事是,它显然会下载作为当前 react 器一部分的 Artifact 的远程快照(请参阅上面片段中的“下载”消息)。我应该指出,尽管有所有这些重复的消息,但目标已经实现:生成了聚合 javadoc,并包含在程序集中。

所以,问题真的是:我做错了什么(如果有的话)?我应该忽略这些重复的“ fork ”消息和快照下载,还是表明设置不正确?如果是后者,是否有人知道我应该如何调整设置以使其正常工作?

FWIW 我已经尝试了几种替代配置,包括将 javadoc 插件配置移动到程序集子模块,但都没有给我预期的结果。

我试图保持简短和重点,如果需要更多信息,请告诉我。

顺便说一下,运行 Maven 3.2.3。

最佳答案

我似乎找到了自己问题的答案。

问题出在 javadoc 插件配置中。因为插件位于聚合器项目的构建部分,它被子模块继承(然后每个子模块依次执行它,显然)。

只需确保插件不会被继承即可解决问题:

      <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>false</inherited>
...

关于maven - 在多模块项目中生成聚合 javadoc 时如何避免重复 fork ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27935661/

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