Speeding up assembly of multiple modules

I have a project of the following form

- pom.xml - projectA - pom.xml - src/main/ - java - startupScript - projectB - pom.xml - src/main/ - java - startupScript - projectAssembly - pom.xml 

I want projectAssembly create a tar.gz that contains two folders for ProjectA and one for projectB, in each folder there would be project dependencies and a startupScript library.

The β€œnaive” way to do this is to add the assembly.xml file to each project, which looks something like this:

 <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> 

Then in projectAssembly , it depends on the <type>tar.gz</type> both projectA and projectB , and add an assembly file that looks something like

 <assembly> <dependencySets> <dependencySet> <outputDirectory>/</outputDirectory> <unpack>true</unpack> </dependencySet> </dependencySets> </assembly> 

This works, but I don’t need intermediate tar.gz projects A and B , and it takes a lot of time to create them, especially if they have many dependencies.

How can I tell maven to directly collect only tar.gz projectAssembly without wasting time when packing and unpacking intermediate archives?

+7
source share
1 answer

Your assembly descriptor in the project assembly should look something like this (see comments inside):

 <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> 

I believe that this would be what you need. If not tell us.

+1
source

All Articles