Maven Multi-Module Project

456 views Asked by At

I'm trying to perform a Maven build in a multi-module project structured like the below:

-> Project-Parent
    -> Project-Utils
        - pom.xml
    -> Project-Service
        - pom.xml
    - pom.xml

Given what I've read on advanced Reactor options, I could possibly use the following command to build the Project-Utils project alone:

mvn -pl ./Project-Utils clean install

However, it seems that I would have to define Project-Utils in my parent POM as such:

<modules>
    <module>Project-Utils</module>
</modules>

Is there any way I can use the --project option without having to define modules in the parent POM?

1

There are 1 answers

0
Henry Hoendervangers On

In the module POM make sure you set relativePath

<parent>
    ...
    <relativePath/>
</parent>

This wil make sure maven will search for the parent pom in your repositiory.

To install the parent into the repository, navigate to the parent directory and execute

mvn clean install

and then navigate to the directory of the module and execute

mvn clean package

it should pick up the installed parent