开发者

multi-module maven project

开发者 https://www.devze.com 2022-12-22 13:37 出处:网络
If I have 6 modules in my project is it possible to build only one out of six ? without commenting out others ?

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 w开发者_如何学Pythonithout installing parent


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.


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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号