You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tester <sp...@gmail.com> on 2013/10/16 23:15:42 UTC

Issue with maven antrun in and in tag

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?

Re: Issue with maven antrun in and in tag

Posted by Jörg Schaible <Jo...@scalaris.com>.
Anders Hammar wrote:

> You have the config on plugin level not execution level. So the
> declaration in the profile will get the config in the build section add
> well and execute that. Execute Maven in debug mode and it should be
> visible.

or with 

 mvn help:effective-pom
 mvn -Pintg help:effective-pom

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Issue with maven antrun in and in tag

Posted by Anders Hammar <an...@hammar.net>.
You have the config on plugin level not execution level. So the declaration
in the profile will get the config in the build section add well and
execute that. Execute Maven in debug mode and it should be visible.

/Anders (mobile)
Den 16 okt 2013 23:18 skrev "Tester" <sp...@gmail.com>:

> 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?
>