I have a maven project P that consists of several submodules s1,s2... To make this work, I have the following directory structure:
P
|_pom.xml
|_s1
|_pom.xml
|_..
|_sN
|_pom.xml
In the parent pom.xml
, I have a normal maven setup:
<project xmlns="..." xmlns:xsi="..." xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>P</artifactId>
<version>0.1.0</version>
<packaging>pom</packaging>
<name>P</name>
<modules>
<module>s1</module>
<module>s2</module>
<!-- ... -->
<module>sN</module>
</modules>
<!-- Repos and dependencies go here -->
</project>
And, for each of the child projects, a pom.xml
similar to this one:
<project xmlns="..." xmlns:xsi="..." xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company</groupId>
<artifactId>P</artifactId>
<version>0.1.0</version>
</parent>
<groupId>com.company</groupId>
<artifactId>s1</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
<dependencies>
...
</dependencies>
</project>
Additionally, in the project, I have some inter-module dependencies, so for example s4 might require s1 s2 and s5. In order to make this work, I list the submodules as depencencies of other submodules, so for example, in s4's pom.xml
I would have:
<dependencies>
<dependency>
<groupId>com.company</groupId>
<artifactId>s1</artifactId>
<version>0.1.0</version>
</dependency>
...
</dependencies>
The problem with this setup is that, whenever I compile one of the submodule projects, changes in the other submodules are not seen unless they have been previously installed with mvn install
. That makes sense, since I'm listing the inter-module dependencies with a specific version, and maven goes to the local repository in the .m2
folder to find them.
Is there a way I can tell maven that I'm in charge of all these projects and that it should recursively go and compile other dependent submodules whenever there are changes?