简体   繁体   中英

multi-module maven project

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

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 (ie 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.

打开一个命令shell,导航到子模块目录并执行mvn install (或者你喜欢的生命周期)应该可以解决问题。

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.

在Eclipse中,假设您安装了m2eclipse:右键单击相关模块并选择Run As - > Maven package。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM