We are having an issue on our project, where a maven build is executed with an antrun plugin execution in both the <build> and <profile> tags, it gets messed up. Let's take this example to illustrate the problem (very simplified version):
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <configuration> <tasks> ... deploy to weblogic server .. </tasks> </configuration> <executions> <execution> <phase>deploy</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>intg</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <configuration> <tasks> ... replace a value in file ... </tasks> </configuration> <executions> <execution> <id>0_resource</id> <phase>process-resources</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> Now the problem that we are having is that when we do for example: mvn clean install -Pintg, it first executes the antrun plugin tasks specified in the build tags. Even though it has a deploy phase. When I would delete the antrun plugin in the profile tag, I would not have this issue. It seems that as there are 2 different instances of the antrun plugin, it somehow executes all of them even though they are not in the appropriate phase. What is happening here? Is this a bug? Is it not allowed to have 2 antrun plugins in the same execution of the pom.xml file? I know for example that it is not a problem to have the antrun plugin in a different profile, as long as they are not both called! Apparently it is also not allowed to have 2 antrun plugins defined in the <build> tag, but you should define multiple <executions> with different phases. Could someone please elaborate on this?
