The multi-module project maven

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

EDIT

The submodule will not work in its field, because either parent tags. I need to set the parent first so that it is created. how can i do this without setting the parent

+7
java eclipse maven-2
source share
4 answers

Is it possible to build only one of six? without commenting on others?

I understand that you want to start maven from an aggregation project (i.e. build a reactor), but only build one module. This is possible using the list option -pl , --projects (see advanced reactor parameters ):

 mvn --projects my-submodule install 

This is a very powerful option, especially in combination with --aslo-make (also for creating projects on which the listed modules depend) or --also-make-dependents (also for creating projects that depend on the listed modules). Based on your update, you might want this actually:

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

Running Maven from the directory of the module you want to build is, of course, an option, but it will not allow you to do the things described above and not build a subset of all the modules. For such use cases, extended reactor options are the way to go.

+10
source share

Opening a command shell, navigating to the submodule directory and executing mvn install (or any other preferred life cycle) should do the trick.

+3
source share

You can simply build the module by going to this module directory and running mvn clean install .

However, note that using this method, dependencies on other modules will be taken from your local repository (or Entreprise repository).

Take a simple example:

 project + commons + business 

Now imagine that you are creating the entire project in the root directory using the mvn clean install command. Please note that all your modules are in version 1.0 .

You are now moving to version 1.1 . If you run mvn clean install only in the business project, it will try to get 1.1 commons modules. After that, you will have an error, since Maven will not find any version 1.1 in your local repository.

+2
source share

Inside Eclipse, if you have m2eclipse installed: right-click the appropriate module and select "Run As → Maven Package".

0
source share

All Articles