I would like to run an Ant build.xml
build from a parent POM.
This may look like this:
<project>
<groupId>my.group</groupId>
<artifactId>my-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<tasks>
<ant antfile="build.xml"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This works just fine unless I use this module as a parent POM.
The problem is in this line <ant antfile="build.xml"/>
. While this POM is running as a parent POM there is no build.xml
file available to the plugin.
How can I run an Ant script from a file (located in the parent POM) during all child build?
PS
I tried to package the build.xml
under some classifier to make it available to the children builds. But I have no idea, how can I extract my packaged build.xml
prior to the antrun:run
.
PPS
The project structure:
<root>
+ Parent POM
| +- pom.xml
| +- build.xml
|
+ Component1
| + Child1
| | +- src/main/java
| | +- ...
| | +- pom.xml
| |
| + Child2
| +- src/main/java
| +-...
| +- pom.xml
|
+ Component2
+ Child3
| +- src/main/java
| +- ...
| +- pom.xml
|
+ Child4
+- src/main/java
+-...
+- pom.xml
As a bonus: I also would like to know the answer for the situations, where the parent POM get built and deployed independently (not knowing own child) and children get built having only access to the parent deployed artifacts (not the source code).