Maven: same artifactID in shared plugin and profile build plugin

293 views Asked by At

I have a maven pom.xml which will run some group of ant tasks. Some tasks are only for specific profile and some tasks for common for all profile. This is mine

<build>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                    <tasks>
                        <!-- Some of my common task -->
                    </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
<build>

<profiles>
    <profile>
        <id>developement</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <phase>test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                            <tasks>
                                <!-- Task specifics for profile -->
                            </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        <build>
    </profile>                      
</profiles>

I run the project using the the below command

mvn clean install -P developement

while building this project the common tasks is not running. Tasks in profile only running. Is it happened because of I am using same artifactID in both shared and profile plugin..?

My Env:

Java 1.6 Maven 2.2.1 Windows 7 64 bit

1

There are 1 answers

1
user944849 On BEST ANSWER

Both of the executions shown are missing <id> elements. Thus, Maven uses its default execution ID, and the profile execution overwrites the common one.

To fix, add IDs to both as shown, with values of your choice.

   <!-- common configuration -->
        <executions>
            <execution>
                <id>antrun-common</id>
                <phase>test</phase>
    ....
   <!-- development profile configuration -->
        <executions>
            <execution>
                <id>antrun-development</id>
                <phase>test</phase>