Maven生成的zip文件包含旧的war文件



我有一个多模块Maven项目,我想构建一个zip文件,其中包含要在生产服务器上交付的所有文件,这意味着一个war文件和一堆shell脚本。

以下是我的父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>

war文件是在eloi网络项目中生成的。所以我有一个问题,因为父pom.xml是首先执行的,所以我实际上在构建之前得到了我的zip文件,但使用了旧版本的war文件,如果我先清理,它就会崩溃。我不知道如何解决这个问题。

我通过将zip程序集移动到eloi web模块的pom.xml来解决这个问题。我以前尝试过,但遇到了其他问题,因为${basedir}在模块中与在父目录中的目录不同。一位同事建议使用${basedir}/../,解决了这些问题。不是很优雅,但简单高效。

最新更新