Hello world,

I'm trying to understand how does Maven handle multiple usage of one
plugin in the same POM file.
I created an example POM file with executing maven-antrun-plugin few times:

In default build block, there is echoed Hello A, B and C, in the
profile1, there is echoed D, E, F.
If I run $ mvn install to execute default build, I get C, B, A echoed,
however if I activate profile1, I get A and F echoed. I didn't get the
point, why is it run in this way. Are the multiple configurations
somehow merged, overwritten or so?

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>zztest</groupId>
        <artifactId>profiles-test</artifactId>
        <name>Profiles Test</name>
        <description>Profiles Test</description>
        <packaging>pom</packaging>
        <version>0.1-SNAPSHOT</version>
        <build>
                <plugins>
                        <plugin>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <version>1.3</version>
                                <executions>
                                        <execution>
                                                <id>hello-world-from-buildA</id>
                                                <phase>compile</phase>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                                <configuration>
                                                        <tasks>
                                                                
<echo>************************</echo>
                                                                <echo>* HELLO 
from default A *</echo>
                                                                
<echo>************************</echo>
                                                        </tasks>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                        <plugin>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <version>1.3</version>
                                <executions>
                                        <execution>
                                                <id>hello-world-from-buildB</id>
                                                <phase>compile</phase>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                                <configuration>
                                                        <tasks>
                                                                
<echo>************************</echo>
                                                                <echo>* HELLO 
from default B *</echo>
                                                                
<echo>************************</echo>
                                                        </tasks>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                        <plugin>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <version>1.3</version>
                                <executions>
                                        <execution>
                                                <id>hello-world-from-buildC</id>
                                                <phase>compile</phase>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                                <configuration>
                                                        <tasks>
                                                                
<echo>************************</echo>
                                                                <echo>* HELLO 
from default C *</echo>
                                                                
<echo>************************</echo>
                                                        </tasks>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
        <profiles>
                <profile>
                        <id>profile1</id>
                        <build>
                                <plugins>
                                        <plugin>
                                                
<artifactId>maven-antrun-plugin</artifactId>
                                                <version>1.3</version>
                                                <executions>
                                                        <execution>
                                                                
<id>hello-world-profile1-D</id>
                                                                
<phase>compile</phase>
                                                                <goals>
                                                                        
<goal>run</goal>
                                                                </goals>
                                                                <configuration>
                                                                        <tasks>
                                                                                
<echo>*************************</echo>
                                                                                
<echo>* HELLO from profile1 D *</echo>
                                                                                
<echo>*************************</echo>
                                                                        </tasks>
                                                                </configuration>
                                                        </execution>
                                                </executions>
                                        </plugin>
                                        <plugin>
                                                
<artifactId>maven-antrun-plugin</artifactId>
                                                <version>1.3</version>
                                                <executions>
                                                        <execution>
                                                                
<id>hello-world-profile1-E</id>
                                                                
<phase>compile</phase>
                                                                <goals>
                                                                        
<goal>run</goal>
                                                                </goals>
                                                                <configuration>
                                                                        <tasks>
                                                                                
<echo>*************************</echo>
                                                                                
<echo>* HELLO from profile1 E *</echo>
                                                                                
<echo>*************************</echo>
                                                                        </tasks>
                                                                </configuration>
                                                        </execution>
                                                </executions>
                                        </plugin>
                                        <plugin>
                                                
<artifactId>maven-antrun-plugin</artifactId>
                                                <version>1.3</version>
                                                <executions>
                                                        <execution>
                                                                
<id>hello-world-profile1-F</id>
                                                                
<phase>compile</phase>
                                                                <goals>
                                                                        
<goal>run</goal>
                                                                </goals>
                                                                <configuration>
                                                                        <tasks>
                                                                                
<echo>*************************</echo>
                                                                                
<echo>* HELLO from profile1 F *</echo>
                                                                                
<echo>*************************</echo>
                                                                        </tasks>
                                                                </configuration>
                                                        </execution>
                                                </executions>
                                        </plugin>
                                </plugins>
                        </build>
                </profile>
        </profiles>
</project>



zde...@zdenek:~/test$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Profiles Test
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: hello-world-from-buildC}]
[INFO] Executing tasks
     [echo] ************************
     [echo] * HELLO from default C *
     [echo] ************************
[INFO] Executed tasks
[INFO] [antrun:run {execution: hello-world-from-buildB}]
[INFO] Executing tasks
     [echo] ************************
     [echo] * HELLO from default B *
     [echo] ************************
[INFO] Executed tasks
[INFO] [antrun:run {execution: hello-world-from-buildA}]
[INFO] Executing tasks
     [echo] ************************
     [echo] * HELLO from default A *
     [echo] ************************
[INFO] Executed tasks
[INFO] [site:attach-descriptor]
[INFO] [install:install]
[INFO] Installing /home/zdenek/test/pom.xml to
/home/zdenek/.m2/repository/zztest/profiles-test/0.1-SNAPSHOT/profiles-test-0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Aug 20 10:13:53 CEST 2009
[INFO] Final Memory: 10M/134M
[INFO] ------------------------------------------------------------------------


zde...@zdenek:~/test$ mvn install -P profile1
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Profiles Test
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: hello-world-from-buildA}]
[INFO] Executing tasks
     [echo] ************************
     [echo] * HELLO from default A *
     [echo] ************************
[INFO] Executed tasks
[INFO] [antrun:run {execution: hello-world-profile1-F}]
[INFO] Executing tasks
     [echo] *************************
     [echo] * HELLO from profile1 F *
     [echo] *************************
[INFO] Executed tasks
[INFO] [site:attach-descriptor]
[INFO] [install:install]
[INFO] Installing /home/zdenek/test/pom.xml to
/home/zdenek/.m2/repository/zztest/profiles-test/0.1-SNAPSHOT/profiles-test-0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Aug 20 10:14:02 CEST 2009
[INFO] Final Memory: 10M/135M
[INFO] ------------------------------------------------------------------------

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

Reply via email to