我有一个多模块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-plugin
的{{3}}中的说明在分发模块中组装其他模块的二进制文件。我的POM看起来与教程完全一样。
它按照文档中显示的方式工作。在打包阶段,程序集插件收集分发模块中的其他模块的jar。但正如您所看到的,其他库模块也配置为生成文档和源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)
答案 0 :(得分:1)
<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>
答案 1 :(得分:0)
我不完全确定,你真正需要什么,但也许你可以查看文档来创建一个网站..
这是一个很大的解释,我希望它有所帮助。
答案 2 :(得分:0)
好的,我已经完成了以下选项:
所以,我采取的简单方法如下:
确保所有模块都生成源jar。这可以通过在父pom中启用源插件来完成,该插件由所有模块继承:
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
创建一个特殊的“构建”模块,以组合所有其他模块的源。这是通过使用maven-dependency-plugin
的{{1}}目标和源分类器来完成的。这意味着将所有其他模块源组合为此模块的源。
构建模块的pom:
unpack-dependencies
现在,构建模块像任何其他项目一样编译,生成所有必需的jar。