1
我有一个相当大的超过200个模块的java maven项目,它可以。我试图将所有这些模块合并到单个jar中。如何使用多个子模块从maven项目创建单个库jar?
在某些情况下,只声明一个新的maven依赖项会非常方便,例如。 my-library-5.2.4-SNAPSHOT-bundle.jar或类似的新项目。
我试过使用maven assembly-plugin。我可以创建新的jar文件,jar包含所有的模块jar,并且如果我安装它,它将正确地转到本地.m2文件夹。 Jar可以在其他项目中声明为依赖项。
但问题是我不能在我的java类中导入库中的任何模块。导入不会识别这些内容。
我加入这个build一节我的根pom.xml中:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-bundle</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
而且我assembly.xml看起来是这样的:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bundle</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<binaries>
<outputDirectory>modules</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
http://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/ –