I have 2 maven projects where one depends on another. Let's call them common
and service
.
service
specifically depends on a module within common
we'll call common-module
.
If I make an update to common-module
and run mvn clean install
, it gets properly installed to my local repository.
Problem
In service
, when I do a mvn clean package/install
or mvn -U clean package/install
will pick up the version that's in the remote repository even though the one I just built is newer. I cannot get it to pick up that latest version even though I see it in my .m2/repository
.
How can I get it to pick my locally built jar?
Setup
pom.xml
for common
(simplified, a lot is excluded)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<artifactId>common-parent</artifactId>
<version>2.4.5-SNAPSHOT</version>
<name>Common Parent</name>
<modules>
<module>common-module</module>
</modules>
</project>
pom.xml
for common-module
(simplified, a lot is excluded)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>common-module</artifactId>
<name>common-module</name>
<description>common-module</description>
<parent>
<artifactId>common-parent</artifactId>
<groupId>com.company.group</groupId>
<version>2.4.5-SNAPSHOT</version>
</parent>
</project>
pom.xml
for service
(simplified, a lot is excluded)
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>service</artifactId>
<name>service</name>
<version>1.2.3-SNAPSHOT</version>
<dependencies>
<dependency>
<artifactId>common-module</artifactId>
<groupId>com.company.group</groupId>
<version>2.4.5-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Note 1: I have a workaround where I can adjust the library settings within IntelliJ and force it to use the correct jar file, but this feels very hacky and unsustainable to me.
Note 2: I've tried changing the <updatePolicy>
value in my settings.xml
to never
and other values, but it seems to have had no effect. This was suggested in other posts I've read before asking here.
<repository>
<id>snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
<url>http://internal.url/repository/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>