Suppose I have a mutli-module maven project; sometimes I try to run something like mvn test
and maven complains that it can't load some module from maven central. And of course, it's true. The code exists only on my laptop. So run "mvn install" so load the module in my local maven repo. But this is not nice. The module now exists in two places, and they might get out of sync. Is there a way to avoid this step and have maven look for the module in the right place?
EDIT: I was asked for a working example, so here's a small-ish one with three pom.xml files
First, we have parent/pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>this-is-our-group</groupId>
<artifactId>this-is-the-parent</artifactId>
<version>some-version</version>
<packaging>pom</packaging>
<modules>
<module>../core</module>
<module>../util</module>
</modules>
</project>
Then we have core/pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>util-is-you-till</artifactId>
<parent>
<groupId>this-is-our-group</groupId>
<artifactId>this-is-the-parent</artifactId>
<version>some-version</version>
</parent>
</project>
And finally util/pom.xml
is basically the same as core
except for the artifact ID:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>util-is-you-till</artifactId>
<parent>
<groupId>this-is-our-group</groupId>
<artifactId>this-is-the-parent</artifactId>
<version>some-version</version>
</parent>
</project>
We put the above files in the obvious directory hierarchy, and then run mvn test -f parent/pom.xml
. Maven will immediately start trying to fetch these things from central, even though they are meant to be all local.
Any fix?