Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build single module from multimodule pom

Tags:

maven

Is it possible to do?

The environment: Multimodule pom consists of 3 modules: mm1, mm2, mm3. Module mm2 has mm1 as dependency. It is possible to build parent pom without any errors.

The question: Is it possible to build single module mm2 (i.e., run maven from mm2 base directory) without installing mm1 into local repository?

Thanks.

like image 911
igorp1024 Avatar asked Oct 23 '09 11:10

igorp1024


People also ask

How do I create a sub module in Maven?

From your workspace navigate to File → New → Other and from the wizard selection screen select Maven → Maven Module. Type a name for the module in the Module Name field. Click the Browse button beside the Parent Project field. This will launch a project selection box.

Can we have multiple POM xml files in a single Maven project?

Yes you can use Maven Profiles to manage this. Obviously you can tweak this approach to suit your needs however works best.

How do I create a sub module in a spring boot project?

Change or add '<packaging>pom</packaging>' . Add a sub-module ( Right click on Parent Module -> New -> other -> Maven -> Maven Module -> Next ( Select both checkboxes ) -> Next -> jar or war -> Finish ).

How do I add one project as dependency in Maven?

Add a Java Maven Dependency to the Utility ProjectRight-click the utility project, and select Maven>Add Dependency. Type a dependency name in the Enter groupID… field (e.g., commons-logging) to search for a dependency. Select the dependency, and click OK.


1 Answers

I'm not sure what you mean exactly by "without installing mm1 into local repository". Do you mean previously to building mm2 or never?

In doubt, maybe one of the new build options announced in the Maven Tips and Tricks: Advanced Reactor Options blog post can help:

Starting with the Maven 2.1 release, there are new Maven command line options which allow you to manipulate the way that Maven will build multimodule projects. These new options are:

-rf, --resume-from
        Resume reactor from specified project
-pl, --projects
        Build specified reactor projects instead of all projects
-am, --also-make
        If project list is specified, also build projects required by the list
-amd, --also-make-dependents
        If project list is specified, also build projects that depend on projects on the list

I was specifically thinking to the -pl and -am options. To build a subset of the modules, run the following from the root directory

$ mvn --projects mm2 --also-make install

However, I'm not sure this answers your question (which is not totally clear for me).

like image 57
Pascal Thivent Avatar answered Oct 03 '22 06:10

Pascal Thivent