You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org> on 2010/08/14 16:50:32 UTC

[jira] Updated: (MNG-1847) Incorrect configuration merging when using multiple executions of antrun

     [ http://jira.codehaus.org/browse/MNG-1847?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann updated MNG-1847:
-----------------------------------

    Description: 
I've encovered strange behaviour of maven while merging configuration. I've prepared two test cases.

The first one shows how executions from different phases and profiles are incorrectly merged. One antrun execution is in main build element in package phase. Second antrun execution is in 'foo' profile in validation phase. When running mvn using this profile with default goal (validate), maven is merging two antrun executions (but not completely). 
{code:xml}
<project>
 <modelVersion>4.0.0</modelVersion>
 <groupId>testcase</groupId>
 <artifactId>test2</artifactId>
 <version>1.0</version>

 <build>
  <plugins>
   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <phase>package</phase>
      <configuration>
       <tasks>
        <echo>main build</echo>
        <mkdir dir="fooo"/>
        <delete dir="fooo"/>
       </tasks>
      </configuration>
      <goals>
       <goal>run</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>

 <profiles>
  <profile>
   <id>foo</id>
   <build>
    <defaultGoal>validate</defaultGoal>
    <plugins>
     <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
       <execution>
        <phase>validate</phase>
        <configuration>
         <tasks>
          <echo>Foo profile</echo>
         </tasks>
        </configuration>
        <goals>
         <goal>run</goal>
        </goals>
       </execution>
      </executions>
     </plugin>
    </plugins>
   </build>
  </profile>
 </profiles>
</project>
{code}
{noformat}
C:\test2>mvn -Pfoo
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Unnamed - testcase:test2:jar:1.0
[INFO]    task-segment: [validate]
[INFO] ----------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Foo profile
    [mkdir] Created dir: P:\maven\testcase\test2\fooo
   [delete] Deleting directory P:\maven\testcase\test2\fooo
[INFO] Executed tasks
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Dec 15 15:43:23 CET 2005
[INFO] Final Memory: 2M/4M
[INFO] ----------------------------------------------------------------------------
{noformat}



The second testcase shows how different executions of antrun are incorrectly merged. There are two different antrun executions. One in compile phase and one in package phase. They should 'echo' different messages, but they DON'T.
{code:xml}
<project>
 <modelVersion>4.0.0</modelVersion>

 <groupId>testcase</groupId>
 <artifactId>test1</artifactId>
 <name>test1</name>
 <version>1.0</version>

 <build>
  <defaultGoal>package</defaultGoal>
  <plugins>
   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <phase>compile</phase>
      <configuration>
       <tasks>
        <echo>main build / compile phase</echo>
       </tasks>
      </configuration>
      <goals>
       <goal>run</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <phase>package</phase>
      <configuration>
       <tasks>
        <echo>main build / package phase</echo>
       </tasks>
      </configuration>
      <goals>
       <goal>run</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>
</project>
{code}
{noformat}
c:\test1>mvn
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building test1
[INFO]    task-segment: [package]
[INFO] ----------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] No sources to compile
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] main build / compile phase
[INFO] Executed tasks
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [surefire:test]
[INFO] No tests to run.
[INFO] [jar:jar]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: P:\maven\testcase\test1\target\test1-1.0.jar
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] main build / compile phase
[INFO] Executed tasks
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Thu Dec 15 15:36:03 CET 2005
[INFO] Final Memory: 3M/7M
[INFO] ----------------------------------------------------------------------------
{noformat}

I've attached both poms.



  was:
I've encovered strange behaviour of maven while merging configuration. I've prepared two test cases.

The first one shows how executions from different phases and profiles are incorrectly merged. One antrun execution is in main build element in package phase. Second antrun execution is in 'foo' profile in validation phase. When running mvn using this profile with default goal (validate), maven is merging two antrun executions (but not completely). 

<project >
 <modelVersion>4.0.0</modelVersion>
 <groupId>testcase</groupId>
 <artifactId>test2</artifactId>
 <version>1.0</version>

 <build>
  <plugins>
   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <phase>package</phase>
      <configuration>
       <tasks>
        <echo>main build</echo>
        <mkdir dir="fooo"/>
        <delete dir="fooo"/>
       </tasks>
      </configuration>
      <goals>
       <goal>run</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>

 <profiles>
  <profile>
   <id>foo</id>
   <build>
    <defaultGoal>validate</defaultGoal>
    <plugins>
     <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
       <execution>
        <phase>validate</phase>
        <configuration>
         <tasks>
          <echo>Foo profile</echo>
         </tasks>
        </configuration>
        <goals>
         <goal>run</goal>
        </goals>
       </execution>
      </executions>
     </plugin>
    </plugins>
   </build>
  </profile>
 </profiles>
</project>


C:\test2>mvn -Pfoo
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Unnamed - testcase:test2:jar:1.0
[INFO]    task-segment: [validate]
[INFO] ----------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Foo profile
    [mkdir] Created dir: P:\maven\testcase\test2\fooo
   [delete] Deleting directory P:\maven\testcase\test2\fooo
[INFO] Executed tasks
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Dec 15 15:43:23 CET 2005
[INFO] Final Memory: 2M/4M
[INFO] ----------------------------------------------------------------------------




The second testcase shows how different executions of antrun are incorrectly merged. There are two different antrun executions. One in compile phase and one in package phase. They should 'echo' different messages, but they DON'T.

<project>
 <modelVersion>4.0.0</modelVersion>

 <groupId>testcase</groupId>
 <artifactId>test1</artifactId>
 <name>test1</name>
 <version>1.0</version>

 <build>
  <defaultGoal>package</defaultGoal>
  <plugins>
   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <phase>compile</phase>
      <configuration>
       <tasks>
        <echo>main build / compile phase</echo>
       </tasks>
      </configuration>
      <goals>
       <goal>run</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <phase>package</phase>
      <configuration>
       <tasks>
        <echo>main build / package phase</echo>
       </tasks>
      </configuration>
      <goals>
       <goal>run</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>
</project>

c:\test1>mvn
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building test1
[INFO]    task-segment: [package]
[INFO] ----------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] No sources to compile
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] main build / compile phase
[INFO] Executed tasks
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [surefire:test]
[INFO] No tests to run.
[INFO] [jar:jar]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: P:\maven\testcase\test1\target\test1-1.0.jar
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] main build / compile phase
[INFO] Executed tasks
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Thu Dec 15 15:36:03 CET 2005
[INFO] Final Memory: 3M/7M
[INFO] ----------------------------------------------------------------------------


I've attached both poms.




> Incorrect configuration merging when using multiple executions of antrun
> ------------------------------------------------------------------------
>
>                 Key: MNG-1847
>                 URL: http://jira.codehaus.org/browse/MNG-1847
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Inheritance and Interpolation
>    Affects Versions: 2.0, 2.0.1
>         Environment: windows xp, maven 2.0
>            Reporter: Michal Stochmialek
>             Fix For: Issues to be reviewed for 3.x
>
>         Attachments: testcase.zip
>
>
> I've encovered strange behaviour of maven while merging configuration. I've prepared two test cases.
> The first one shows how executions from different phases and profiles are incorrectly merged. One antrun execution is in main build element in package phase. Second antrun execution is in 'foo' profile in validation phase. When running mvn using this profile with default goal (validate), maven is merging two antrun executions (but not completely). 
> {code:xml}
> <project>
>  <modelVersion>4.0.0</modelVersion>
>  <groupId>testcase</groupId>
>  <artifactId>test2</artifactId>
>  <version>1.0</version>
>  <build>
>   <plugins>
>    <plugin>
>     <artifactId>maven-antrun-plugin</artifactId>
>     <executions>
>      <execution>
>       <phase>package</phase>
>       <configuration>
>        <tasks>
>         <echo>main build</echo>
>         <mkdir dir="fooo"/>
>         <delete dir="fooo"/>
>        </tasks>
>       </configuration>
>       <goals>
>        <goal>run</goal>
>       </goals>
>      </execution>
>     </executions>
>    </plugin>
>   </plugins>
>  </build>
>  <profiles>
>   <profile>
>    <id>foo</id>
>    <build>
>     <defaultGoal>validate</defaultGoal>
>     <plugins>
>      <plugin>
>       <artifactId>maven-antrun-plugin</artifactId>
>       <executions>
>        <execution>
>         <phase>validate</phase>
>         <configuration>
>          <tasks>
>           <echo>Foo profile</echo>
>          </tasks>
>         </configuration>
>         <goals>
>          <goal>run</goal>
>         </goals>
>        </execution>
>       </executions>
>      </plugin>
>     </plugins>
>    </build>
>   </profile>
>  </profiles>
> </project>
> {code}
> {noformat}
> C:\test2>mvn -Pfoo
> [INFO] Scanning for projects...
> [INFO] ----------------------------------------------------------------------------
> [INFO] Building Unnamed - testcase:test2:jar:1.0
> [INFO]    task-segment: [validate]
> [INFO] ----------------------------------------------------------------------------
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Foo profile
>     [mkdir] Created dir: P:\maven\testcase\test2\fooo
>    [delete] Deleting directory P:\maven\testcase\test2\fooo
> [INFO] Executed tasks
> [INFO] ----------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO] ----------------------------------------------------------------------------
> [INFO] Total time: 1 second
> [INFO] Finished at: Thu Dec 15 15:43:23 CET 2005
> [INFO] Final Memory: 2M/4M
> [INFO] ----------------------------------------------------------------------------
> {noformat}
> The second testcase shows how different executions of antrun are incorrectly merged. There are two different antrun executions. One in compile phase and one in package phase. They should 'echo' different messages, but they DON'T.
> {code:xml}
> <project>
>  <modelVersion>4.0.0</modelVersion>
>  <groupId>testcase</groupId>
>  <artifactId>test1</artifactId>
>  <name>test1</name>
>  <version>1.0</version>
>  <build>
>   <defaultGoal>package</defaultGoal>
>   <plugins>
>    <plugin>
>     <artifactId>maven-antrun-plugin</artifactId>
>     <executions>
>      <execution>
>       <phase>compile</phase>
>       <configuration>
>        <tasks>
>         <echo>main build / compile phase</echo>
>        </tasks>
>       </configuration>
>       <goals>
>        <goal>run</goal>
>       </goals>
>      </execution>
>     </executions>
>    </plugin>
>    <plugin>
>     <artifactId>maven-antrun-plugin</artifactId>
>     <executions>
>      <execution>
>       <phase>package</phase>
>       <configuration>
>        <tasks>
>         <echo>main build / package phase</echo>
>        </tasks>
>       </configuration>
>       <goals>
>        <goal>run</goal>
>       </goals>
>      </execution>
>     </executions>
>    </plugin>
>   </plugins>
>  </build>
> </project>
> {code}
> {noformat}
> c:\test1>mvn
> [INFO] Scanning for projects...
> [INFO] ----------------------------------------------------------------------------
> [INFO] Building test1
> [INFO]    task-segment: [package]
> [INFO] ----------------------------------------------------------------------------
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:compile]
> [INFO] No sources to compile
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] main build / compile phase
> [INFO] Executed tasks
> [INFO] [resources:testResources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:testCompile]
> [INFO] No sources to compile
> [INFO] [surefire:test]
> [INFO] No tests to run.
> [INFO] [jar:jar]
> [WARNING] JAR will be empty - no content was marked for inclusion!
> [INFO] Building jar: P:\maven\testcase\test1\target\test1-1.0.jar
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] main build / compile phase
> [INFO] Executed tasks
> [INFO] ----------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO] ----------------------------------------------------------------------------
> [INFO] Total time: 4 seconds
> [INFO] Finished at: Thu Dec 15 15:36:03 CET 2005
> [INFO] Final Memory: 3M/7M
> [INFO] ----------------------------------------------------------------------------
> {noformat}
> I've attached both poms.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira