Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Not A Bug
-
Affects Version/s: 2.0, 2.0.1
-
Fix Version/s: None
-
Component/s: Inheritance and Interpolation
-
Labels:None
-
Environment:windows xp, maven 2.0
-
Complexity:Intermediate
-
Number of attachments :
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).
<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.
Issue Links
- relates to
-
MNG-1701
Validate that a plugin is not configured twice in the pom
-
Activity
| Workflow | Maven [ 43708 ] | Maven New [ 48239 ] |
| Fix Version/s | 2.1 [ 11704 ] |
| Fix Version/s | 2.1 [ 11704 ] | |
| Fix Version/s | 2.1.x [ 13142 ] |
| Component/s | Inheritance and Interpolation [ 11570 ] |
| Fix Version/s | 3.0 [ 13142 ] | |
| Fix Version/s | 3.x [ 13145 ] |
| 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). <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. |
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. |
| Status | Open [ 1 ] | Closed [ 6 ] |
| Assignee | Benjamin Bentmann [ bentmann ] | |
| Fix Version/s | Issues to be reviewed for 3.x [ 13145 ] | |
| Resolution | Not A Bug [ 6 ] |
The second sample is wrong, you should use two executions, not two plugin configs, and it's a dupe of
MNG-1701