3

Possible Duplicate:
How do I exclude certain modules from a maven build using the commandline

I am running a maven clean install in a pom file which includes several modules (and sub-modules). I was wondering if it is possible to run a maven build but specifying on command line to skip a module from the build ( at the moment I exclude them manually from the build, but Id prefer to do it via command line).

I know that with -pl you can selectively choose projects, but what I would like is to selectively exclude (in a blacklist fashion) some.

Community
  • 1
  • 1
Thomas
  • 2,751
  • 5
  • 31
  • 52

1 Answers1

6

You could have a separate <modules> section in a profile, and activate the profile you need in the command line.

Example:

<profiles>
    <profile>
       <id>profile-1</id>
       <activation>
         <activeByDefault>true</activeByDefault>
       </activation>
       <modules>...</modules> <!-- module set 1 -->
    </profile>
    <profile>
       <id>profile-2</id>
       <modules>...</modules> <!-- module set 2 -->
    </profile>
</profiles>

Now, dependent on your current need, execute

mvn install
mvn install -P profile-2

Note that you'd have to think it over carefully, there must be no cross-profile dependencies on the excluded module.

MaDa
  • 10,511
  • 9
  • 46
  • 84
  • Thanks for the suggestion, but I was really looking for a command line solution where I do not need to Crete profiles or touch the pom. Apparently there isn't one yet :( – Thomas Nov 09 '12 at 22:31
  • 1
    Excluding a project is not a trivial case for Maven, so I'll venture a guess that it will never be as simple as a command line option. – MaDa Nov 09 '12 at 23:30