[英]How to make maven-javadoc-plugin generate multiple jars?
I have a multi-module project. 我有一个多模块项目。 In the parent pom (which is not the aggregator POM), I'm using maven-javadoc-plugin
. 在父pom(不是聚合器POM)中,我正在使用maven-javadoc-plugin
。 It has two executions, both in the package
phase, one for the jar
goal, and one for the aggregate-jar
goal. 它有两个执行,都在package
阶段,一个用于jar
目标,一个用于aggregate-jar
目标。
This nicely generates a full aggregate Javadoc jar of all the (non-test) classes in the build. 这很好地生成了构建中所有(非测试)类的完整聚合Javadoc jar。
What I need to be able to do is generate TWO Javadoc jars, one exactly as it's generating now, but another that covers a limited set of modules, and possibly excludes particular packages or classes. 我需要做的是生成两个 Javadoc jar,一个与现在生成的完全一样,但是另一个覆盖有限的模块集,并且可能排除特定的包或类。
I thought perhaps that this would require adding TWO "execution" elements, both for the "aggregate-jar" task, but with different configuration values. 我以为这可能需要为“ aggregate-jar”任务添加两个“执行”元素,但要使用不同的配置值。 This didn't appear to do anything. 这似乎没有任何作用。 It just generated a single Javadoc tree, for "all" the classes. 它只是为“所有”类生成了一个Javadoc树。 How do I get this done? 我该如何完成?
This was my attempt to make this happen: 这是我尝试实现的目标:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>module-javadoc-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<show>protected</show>
<detectLinks>true</detectLinks>
</configuration>
</execution>
<execution>
<id>aggregated-documentation-all</id>
<phase>package</phase>
<inherited>false</inherited>
<goals>
<goal>aggregate-jar</goal>
</goals>
<configuration>
<sourcepath>
../something-api:
../something-impl:
../something-else-api:
../something-else-impl:
</sourcepath>
<destDir>all</destDir>
<finalName>all</finalName>
<show>protected</show>
<detectLinks>true</detectLinks>
</configuration>
</execution>
<execution>
<id>aggregated-documentation-interface</id>
<phase>package</phase>
<inherited>false</inherited>
<goals>
<goal>aggregate-jar</goal>
</goals>
<configuration>
<sourcepath>
../something-api:
../something-else-api:
</sourcepath>
<destDir>interface</destDir>
<finalName>interface</finalName>
<show>protected</show>
<detectLinks>true</detectLinks>
</configuration>
</execution>
</executions>
</plugin>
Probably you are missing an important part there in the <configuration>
and ie <classifier>
可能您缺少了<configuration>
和<classifier>
的重要部分
What is the purpose of Classifier tag in maven? Maven中的Classifier标签的目的是什么?
So your execution phases shall work just fine 因此您的执行阶段应该可以正常工作
<configuration>
<classifier>aggregated-documentation-all</classifier>
....
</configuration>
...
...
<configuration>
<classifier>aggregated-documentation-interface</classifier>
....
</configuration>
Source - Ant to Maven - multiple build targets answer from @Tim O'Brien 来源 -从蚂蚁到 Maven-@Tim O'Brien的多个构建目标答案
Useful Insights - Maven JAR plugin 有用的见解 -Maven JAR插件
Disclaimer - Why-you-shouldnt? 免责声明 - 为什么要这么做?
Edit1 - Noticed further from comments that your pom is an aggregator pom.xml in which case would suggest you use - Edit1-从注释中进一步注意到,您的pom是聚合器pom.xml,在这种情况下,建议您使用-
<inherited>true</inherited>
and also keep a point of specifying different <destDir>
for different executions
to confirm looking at the different outputs. 并且还要为不同的executions
指定不同的<destDir>
以确认查看不同的输出。
Edit2 - To clarify more using an example. Edit2-用一个例子来阐明更多。 What worked for me here was editing the parent modules pom.xml to include the below stated. 在这里对我有用的是编辑父模块pom.xml以包括以下内容。 Executing mvn clean install
generates two different /target
folder for this change using different configuration specified in the executions - 执行mvn clean install
使用执行中指定的不同配置为此更改生成两个不同的/target
文件夹-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<!--This shall generate the package inside the /target folder of parent module-->
<id>first</id>
<phase>package</phase>
<inherited>true</inherited>
<goals>
<goal>aggregate-jar</goal>
</goals>
<configuration>
<classifier>first</classifier>
<show>protected</show>
<detectLinks>true</detectLinks>
</configuration>
</execution>
<execution>
<!--This shall generate the /target on project.basedir of your project-->
<id>second</id>
<phase>package</phase>
<inherited>true</inherited>
<goals>
<goal>aggregate-jar</goal>
</goals>
<configuration>
<destDir>${project.basedir}</destDir>
<classifier>second</classifier>
<!--Notice the package in this /target would not include following packages-->
<excludePackageNames>com.xyz.in.my.project</excludePackageNames>
<finalName>second</finalName>
<show>protected</show>
<detectLinks>true</detectLinks>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.