Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build second level+ child projects using reactor option -pl

Tags:

maven

My maven project structure is as below

Project A 
  pom.xml
  - ProjectB
    pom.xml
    - ProjectC
      pom.xml
    - ProjectD
      pom.xml
  - ProjectY
    pom.xml

By using maven reactor options i can

clean install -pl projectB or clean install -pl projectY

But while trying to build the second level child modules using clean install -pl projectC, maven throws

org.apache.maven.MavenExecutionException: Could not find the selected project in the reactor: projectC

how to build the second level+ child modules using maven reactor options

like image 735
Bachan-user3143666 Avatar asked Apr 15 '14 05:04

Bachan-user3143666


People also ask

What is reactor project in Maven?

The reactor is the part of Maven that allows it to execute a goal on a set of modules. As mentioned in the Maven 1. x documentation on multi-modules builds (the reactor concept was already there in Maven 1.

Does Maven support multi project build?

As seen in the introduction to the POM, Maven supports project aggregation in addition to project inheritance. This section outlines how Maven processes projects with multiple modules, and how you can work with them more effectively.

How do you create a multi-module project?

POM Aggregator (Parent POM) Let's understand the structure of the multi-module application that we have created. Step 1: Create a Maven Project with the name spring-boot-multimodule. Step 2: Open the pom. xml (parent pom) file and change the packaging type jar to pom.

What is the use of multilevel Maven project?

A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.

What is a reactor in Maven?

The Reactor. The mechanism in Maven that handles multi-module projects is referred to as the reactor. This part of the Maven core does the following: Collects all the available modules to build. Sorts the projects into the correct build order. Builds the selected projects in order.

What is the-RF or--resume-from option in Maven reactor?

The -rf or --resume-from option can come in handy if you want to tell the Maven Reactor to resume a build from a particular project.

How do I run a Maven project in a large build?

If you wanted to run a portion of the larger build, you would use the-pl or --projects option with the-am or --also-make option. When you specify a project with the-am option, Maven will build all of the projects that the specified project depends upon (either directly or indirectly).

How does Maven process projects with multiple modules?

As seen in the introduction to the POM, Maven supports project aggregation in addition to project inheritance. This section outlines how Maven processes projects with multiple modules, and how you can work with them more effectively. The mechanism in Maven that handles multi-module projects is referred to as the reactor.


1 Answers

From the documentation for the -pl option it states the following:

-pl,--projects <arg>                Comma-delimited list of specified
                                    reactor projects to build instead
                                    of all projects. A project can be
                                    specified by [groupId]:artifactId
                                    or by its relative path.

The important part for you is: "or by its relative path".

So to build projectC, you simply need to refer to it by its relative path (projectB/projectC). So the command you need is:

mvn clean install -pl projectB/projectC
like image 128
DB5 Avatar answered Jan 23 '23 17:01

DB5