I have a Maven project that consists of several modules. I have a single POM file that I use to invoke the build of all dependent modules. What I want to do is to copy a bunch of files to a single location and zip them up once, after the package lifecycle of all the sub-modules has completed.
I've looked into antrun, but can't see how to make it run once. Currently it runs during the package phase of each module. Here's my parent POM file (simplified)
<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" destfi开发者_JAVA技巧le="dist.zip"></zip>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
...
</properties>
Hopefully it's clear what I'm trying to do. I just want the antrun task to happen after the package lifecycle, and only once, not for each module.
I understand that I might not be approaching this step the right way, but I'm unclear how best to aproach this with Maven. Any thoughts appreciated.
Try the Maven Assembly Plugin.
Here are the Maven Assembly Plugin Examples.
精彩评论