0

I have project like

module1
module2
module3
 submodule1
    src
      main
        java
        resources
    child1
    child2
module4

When I run mvn clean install on the project all top and submodules builds. But I want maven not to execute child1, child2. How I can do that. I found that using profiles I can do that. But how? Can I do something in submodule1 pom so that child1, child2 exclude from the maven phases ?

MAK Ripon
  • 1,065
  • 4
  • 14
  • 27

1 Answers1

1

Yes that's easy enough. In submodule1's pom, by default you only include src:

<modules>
    <module>src</module>
</modules>

Then in a special profile, disabled by default, you build all of them

<profiles>
    <profile>
        <id>src-extra</id>
        <modules>
            <module>src</module>
            <module>child1</module>
            <module>child1</module>
        </modules>
    </profile>
</profiles>

However, you should also investigate the --also-make and --also-make-depends options, which might allow you to do what you want without any POM changes or extra profiles.

artbristol
  • 32,010
  • 5
  • 70
  • 103
  • 1
    Basically I want to do that by pom changes. Not by command line. Because my project builds in a server where other projects also build. There a common clean install command used for all projects. – MAK Ripon May 24 '12 at 08:38
  • src is not a module also. Source is the source folder for the module. – MAK Ripon May 24 '12 at 08:44
  • It's not advisable to mix aggregator modules (ones with `` sections) and modules that produce artifacts. I advise you to move `child1` and `child2` into a sibling directory of `sub-module1` and make it depend on them. – artbristol May 24 '12 at 08:49