Build sibling projects when running mvn install

214 views Asked by At

We have a project that recently switched from ant and crappy CLI tools to maven,
our current structure is:

- parent
    - main-project:
    - sub-module-A:
    - sub-module-B:

Each one of these projects is in it's own repository and they are linked through pom files parent has all three projects defined in tags and main-project defines both sub modules as dependencies.

the issue at hand:
Since main-project is where I deploy the site (in this case) I want to make sure that the sources of both modules are updated when I run it which means I want to compile if needed both sub modules when I run mvn install on the main-project.

I tried using mvn-exec-plugin to build both but it's not actually building anything.

Any idea how to fix this?

edit: I am running mvn appengine:run from main-project and want the sources from sub-modules A and B to install if needed

1

There are 1 answers

1
SilverNak On

Assuming your main-project has dependencies on sub-module-A and sub-module-B and the parent has all projects as modules, i. e.

parent

<modules>
    <module>main-project</module>
    <module>sub-module-A</module>
    <module>sub-module-B</module>
<modules>

main-project

<dependencies>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>sub-module-A</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>sub-module-B</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

Then, you can build the parent project with

mvn --projects :main-project --also-make install

or using shortcuts for the options

mvn -pl :main-project -am install

With these options only the main-project and all its dependencies (which are somewhere in the parent's modules) are built.

See this and this for more information.