我有一个以下形式的项目
- pom.xml
- projectA
- pom.xml
- src/main/
- java
- startupScript
- projectB
- pom.xml
- src/main/
- java
- startupScript
- projectAssembly
- pom.xml我希望projectAssembly生成一个tar.gz,其中包含两个文件夹,一个用于projectA,一个用于projectB,每个文件夹中都有项目的依赖项和startupScript库。
“天真”的方法是将assembly.xml文件添加到每个项目中,该文件大致如下:
<assembly>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/${project.artifactId}</baseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/startupScripts</directory>
<outputDirectory>/startupScripts</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>然后,在projectAssembly中,依赖于projectA和projectB的<type>tar.gz</type>,并添加一个大致类似于
<assembly>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</assembly>这是可行的,但是,我不需要项目A和B的中间tar.gz,并且生成它们需要很长时间,特别是当它们有很多依赖项的时候。
我如何告诉maven直接汇编projectAssembly的tar.gz,而不是浪费时间打包和解包中间文件?
发布于 2013-05-14 14:19:10
您在projectAssembly中的程序集描述符需要如下所示(请参阅内部注释):
<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>bin</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<!-- Enable access to all projects in the current multimodule build! -->
<useAllReactorProjects>true</useAllReactorProjects>
<!-- Now, select which projects to include in this module-set. -->
<includes>
<include>*:projectA</include>
<include>*:projectB</include>
</includes>
<!-- Select and map resources from each module -->
<sources>
<includeModuleDirectory>false</includeModuleDirectory>
<fileSets>
<fileSet>
<directory>src/main/startupScript</directory>
<outputDirectory>${module.artifactId}/startupScript</outputDirectory>
</fileSet>
</fileSets>
</sources>
<!-- Select and map dependencies from each module -->
<binaries>
<dependencySets>
<dependencySet>
<outputDirectory>${module.artifactId}/lib</outputDirectory>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>我相信这就是你需要的。如果没有,让我们知道..
https://stackoverflow.com/questions/15894283
复制相似问题