我有一个由几个模块组成的Maven项目。我有一个POM文件,我用它来调用所有依赖模块的构建。我想要做的是在所有子模块的包生命周期完成之后,将一堆文件复制到一个位置并将其压缩一次。
我看过antrun,但看不出如何让它运行一次。目前,它在每个模块的包装阶段运行。这是我的父POM文件(简化)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<name>project</name>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>../module1</module>
<module>../module2</module>
</modules>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<mkdir dir="product" />
<copy todir="product">
<fileset dir="../module1/doc/release">
<include name="*.pdf" />
</fileset>
<fileset dir="../module2/doc/release">
<include name="*.pdf" />
</fileset>
<fileset dir="../module1/target">
<include name="*.war" />
</fileset>
<fileset dir="../module2/target">
<include name="*.war" />
</fileset>
</copy>
<copy file="app.properties" todir="cesium" />
<zip basedir="product" destfile="dist.zip"></zip>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
...
</properties>
希望我很清楚我正在尝试做什么。我只是希望antrun任务在包生命周期之后发生,并且只需要一次,而不是每个模块。
我知道我可能不会以正确的方式接近这一步,但我不清楚如何最好地接受Maven。任何想法都赞赏。