3

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 subsystem separately,
e.g. mvn package -P p1and mvn package -P p2

Both profiles are visible but can't be activated with -P switch

mvn help:all-profiles -P p1

That work with other project

What is missing here to activate profile or what is better way to build subsystem?

I have read How to activate a Maven profile in a dependent module?

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332

3 Answers3

6

your problem is that by declaring

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

Those are always built. Just delete your first 4 lines and it will work as expected.

Now you can build MavenModule1 by typing:

-P p1

Both by typing:

-P p1,p2

and so forth.

mediahype
  • 480
  • 2
  • 8
5

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

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

Aivean
  • 10,692
  • 25
  • 39
-1

You should remove that space and it should work fine.

use

mvn package -Pp1

Syed Siraj Uddin
  • 583
  • 1
  • 5
  • 13