我有一個由幾個模塊組成的Maven項目。我有一個POM文件用於調用所有相關模塊的構建。我想要做的是在所有子模塊的包生命週期完成後,將一堆文件複製到一個位置並壓縮一次。Maven多個模塊 - 後包裝步驟
我查看了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解決這個問題。任何想法讚賞。
嘿,既然mohommad shamsi給了你一個很好的答案,請確保你將他的答案標記爲已接受的答案。 – deterb 2010-09-06 20:14:50