views:

215

answers:

4

If I have 6 modules in my project is it possible to build only one out of six ? without commenting out others ?

EDIT

Submodule will not work itselft because or parent tags. I need to install the parent first to make it build. how can I do it without installing parent

+1  A: 

Opening a command shell, navigating to the submodule directory and executing mvn install (or whatever your preferred lifecycle is) should do the trick.

Péter Török
+1 For the simple approach.
Robin
@Péter Török I Updated my question .. your solutions is simplest so far .. I can't build submodule .. I need to install the parent first because submodule will not work itselft because or parent tags.
Gandalf StormCrow
@Gandalf StormCrow That's a more complicated story then... I stand aside to humbly watch @Pascal perform his magic :-)
Péter Török
Indeed its a kind of magic
Gandalf StormCrow
+1  A: 

You can simply build the module by going in this module directory and run the mvn clean install.

However, note that with this method, the dependencies with the others modules will be taken from your local repository (or the entreprise repository).

Let's take a simple example:

project
  + commons
  + business

Now, imagine that you build, on the root directory the whole project, using the mvn clean install command. Consider that all your modules are in version 1.0.

Now, you move to version 1.1. If you run the mvn clean install on the business project only, it will try to get the 1.1 of module commons. You will then have an error, as Maven will not find any version 1.1 in your local repository.

romaintaz
A: 

Within Eclipse, assuming you have m2eclipse installed: Right-click on the module in question and choose Run As -> Maven package.

Robert Wilson
+7  A: 

is it possible to build only one out of six ? without commenting out others ?

My understanding is that you want to launch maven from the aggregating project (i.e. a reactor build) but only build one module. This is possible using the -pl, --projects project list option (see advanced reactor options):

mvn --projects my-submodule install

This is a very powerful option, especially when combined with --aslo-make (to also build the projects on which the listed modules depend) or the --also-make-dependents (to also build the projects that depends on the listed modules). On the basis of your update, you might want this actually:

mvn --projects my-submodule --also-make install

Launching Maven from the directory of the module you want to build is of course an option but this won't allow you to do the things mentioned above nor to build a subset of all modules. For such use cases, the advanced reactor options are the way to go.

Pascal Thivent