Kiran Mohan
Kiran Mohan

Reputation: 3006

maven profile based and non-profile based plugin execution

I have pom.xml with the following contents.

<profiles>
    <profile>
        <id>P1</id>
        <build>
            ... some exec-maven-plugin entries
        </build>
    </profile>
    <profile>
        <id>P2</id>
        <build>
            ... some exec-maven-plugin entries
        </build>
    </profile>
<profiles>

<build>
    ... some more (but common for all) exec-maven-plugin entries
</build>

Only one of the profile P1 or P2 is activated from command line. But whatever the selected profile, it is expected that plugins in the common section (i.e., the build section outsides the profiles) should also execute. It is also expected that the plugins both in the profile and the common section get executed in the order of configured phase.

Now the build works with maven2 but fails with maven3. I have not been to able to debug this exactly.

With Maven3, would this work as expected?
In what order would the plugins get executed?
Or is it only the selected profile that alone builds?

UPDATE: The common build does get executed. There were conflicting execution IDs in common and in one of the profile. So it failed.

Upvotes: 1

Views: 924

Answers (1)

Essex Boy
Essex Boy

Reputation: 7950

You need something like this:

<profiles>
    <profile>
        <id>P1</id>
        <build>
          .. executed for with -PP1
        </build>
    </profile>
    <profile>
        <id>P2</id>
        <build>
          .. executed for with -PP2
        </build>
    </profile>
    <profile>
        <id>default</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
          .. executed with no profile
        </build>
    </profile>
</profiles>

<build>
  .. executed for in all cases.
</build>

Upvotes: 1

Related Questions