How to activate maven profile from command line (to create subsystem)

I have a Maven project https://github.com/paulvi/MavenMultiModule1

with root pom.xml as

<modules>
    <module>MavenModule1</module>
    <module>MavenModule2</module>
</modules>
<properties>

</properties>
<profiles>
    <profile>
        <id>p1</id>
        <modules>
            <module>MavenModule1</module>
        </modules>
    </profile>
    <profile>
        <id>p2</id>
        <modules>
            <module>MavenModule2</module>
        </modules>
    </profile>
</profiles>

      

I would like to be able to build the subsystem separately
like mvn package -P p1

andmvn package -P p2

Both profiles are visible but cannot be activated with a switch -P

mvn help:all-profiles -P p1

      

This works with another project

What's missing here to activate a profile or a better way to create a subsystem?

I read How to Activate Maven Profile in Dependent Module?

+3


source to share


3 answers


Your problem is that by declaring

<modules>
    <module>MavenModule1</module>
    <module>MavenModule2</module>
</modules>

      

They are always built. Just remove the first 4 lines and it will work as expected.

Now you can create MavenModule1 by typing:



-P p1

      

Both by typing:

-P p1,p2

      

etc.

+6


source


You don't need profiles to build a specific module, use a flag instead -pl

.



http://books.sonatype.com/mvnref-book/reference/_using_advanced_reactor_options.html

+5


source


You must remove this space and it should work fine.

using

mvn package -Pp1

-1


source







All Articles