gpt4 book ai didi

java - Maven 程序集 : bundle docs and sources jars

转载 作者:行者123 更新时间:2023-11-30 11:29:48 24 4
gpt4 key购买 nike

我有一个多模块 Maven 项目。每个库模块生成自己的 jar 输出:

Parent (Pom)
|
Library_01 (jar)
| output:
| |
| lib1.jar
| |
| lib1-docs.jar
| |
| lib1-sources.jar
|
Library_02 (jar)
| output:
| |
| lib2.jar
| |
| lib2-docs.jar
| |
| lib2-sources.jar
|
Distribution (pom) // uses assembly plug-in to assemble outputs of other modules here
output:
|
lib1.jar
|
lib2.jar

我正在按照 maven-assembly-plugindocumentation here 中的解释在 Distribution 模块中组装其他模块的二进制文件.我的 POM 与教程中的完全一样。

它按照文档中显示的方式工作。在打包阶段,程序集插件收集分发模块中其他模块的 jar。但如您所见,其他库模块也配置为生成文档和源 jar。

  1. 如何配置程序集插件来收集其他模块的文档和源代码 jar?

  2. 考虑分配,上面的设置似乎不合适。我最终还是得到了一堆用于不同库的 jar 。是否可以将所有其他模块的类、源代码和文档分别合并到一个 jar 文件中?基本上,我想要分发 3 个全局 jar(二进制文件、文档和源代码)。如何实现?

喜欢:

   |
Distribution (pom)
|
Global.jar (contains classes of Lib1 + Lib2)
|
Global-docs.jar (contains docs of Lib1 + Lib2)
|
Global-sources.jar (contains sources of Lib1 + Lib2)

最佳答案

好吧,我不是专家,但我也在多模块项目中做类似的事情。这是 parent 的 pom 片段,其中指定了插件和文档:

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<properties>
<property>
<name>outputDirectory</name>
<value>${project.build.outputDirectory}</value>
</property>
</properties>
<systemProperties>
<property>
<name>user.language</name>
<value>ca</value>
</property>
<property>
<name>user.country</name>
<value>ES</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<executable>javac</executable>
<source>1.6</source>
<target>1.6</target>
<encoding>ISO-8859-15</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<inherited>true</inherited>
<configuration>
<detectLinks>true</detectLinks>
</configuration>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>site</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<encoding>ISO-8859-15</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.2.1</version>
<inherited>true</inherited>
<configuration>
<ejbVersion>3.0</ejbVersion>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
<generateClient>false</generateClient>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.0</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<!-- <configuration> <links> <link>http://download.oracle.com/javase/6/docs/api/</link>
<link>http://download.oracle.com/javaee/1.4/api/</link> <link>http://static.springsource.org/spring/docs/2.5.x/api/</link>
<link>http://docs.jboss.org/hibernate/core/3.2/api/</link> <link>http://www.easymock.org/api/easymock/2.5.2/</link>
<link>http://testng.org/javadocs/</link> <link>http://www.bouncycastle.org/docs/docs1.6/</link>
<link>http://www.bouncycastle.org/docs/mdocs1.6/</link> <link>http://www.bouncycastle.org/docs/pgdocs1.6/</link>
<link>http://www.bouncycastle.org/docs/tspdocs1.6/</link> </links> </configuration> -->
<executions>
<execution>
<id>agregar</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>pre-site</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</reporting>

关于java - Maven 程序集 : bundle docs and sources jars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18123384/

24 4 0