I have a multi-module Maven projet, and I want to build a zip file containing all of the files to deliver on the production server, which means a war file and a bunch of shellscripts.
Here some extracts from my parent pom.xml:
<modules>
<module>an-fwk</module>
<module>eloi-model</module>
<module>eloi-service</module>
<module>eloi-facade</module>
<module>eloi-web</module>
</modules>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<inherited>false</inherited>
<executions>
<execution>
<id>Génération du livrable 3/5(1) : assemblage de l'archive eloi-batch</id>
<phase>process-sources</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>
${assembly.descriptor.dir}/eloi-batch.xml
</descriptor>
<finalName>eloi-batch</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${basedir}/${livrable.dir}</outputDirectory>
</configuration>
</execution>
<execution>
<id>Génération du livrable 3/5(2) : assemblage de l'archive publicationweb</id>
<phase>process-resources</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>
${assembly.descriptor.dir}/publicationweb.xml
</descriptor>
<finalName>publicationweb</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${basedir}/${livrable.dir}</outputDirectory>
</configuration>
</execution>
<execution>
<id>Génération du livrable 3/5(3) : assemblage de l'archive publicationReferentiel</id>
<phase>process-resources</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>
${assembly.descriptor.dir}/publicationReferentiel.xml
</descriptor>
<finalName>publicationReferentiel</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${basedir}/${livrable.dir}</outputDirectory>
</configuration>
</execution>
<!-- Here I generate the zip file -->
<execution>
<id>Génération du livrable : Création du zip pour Artifactory</id>
<phase>post-site</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>${assembly.descriptor.dir}/zip.xml</descriptor>
</descriptors>
<outputDirectory>${basedir}/artifactory</outputDirectory>
<finalName>${deliverable.file.name}</finalName>
</configuration>
</execution>
</executions>
</plugin>
The war file is generated in the eloi-web project. So I have a problem, because parent pom.xml is executed first, so I actually get the my zip file, but with the old version of the war file, before building, and it crashes if I clean first. I don't know how to solve this issue.
CodePudding user response:
I solved the issue by moving the zip assembly to the pom.xml of the eloi-web module. I tried that before, but got other issues because ${basedir}
is not the same directory in the module than in the parent. A colleague suggested to use ${basedir}/../
, which solved those issues. Not really elegant, but simple and efficient.