jvhashe
jvhashe

Reputation: 1121

Maven not using newer locally built/installed dependency

I've been hitting an annoying issue recently. I have two different maven projects checked out to my development machine. One project depends on the other (let's say Project A depends on Project B), and I actively make changes to both projects. Sometimes though, Project A won't pick up the latest Project B changes. Let's say I make some changes to Project B, I build/install it with...

mvn clean install

I even check my local ~/.m2/repository to see that the jar has been updated. But Project A will still continue to use an older version of Project B. Even though it was just updated... If I remove the entire Project B folder, as in...

rm -rf ~/.m2/repository/project-b/version/

And then build/install Project B again, then at this point my problem is gone. Project A will finally make use of the updated Project B. But I don't want to have to go through this exercise every time. Any clues what could be causing this?

Edit: Here's more or less the relevant parts of the pom.xml for both projects. It's extremely basic.

Project A pom.xml

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.opendaylight.mdsal</groupId>
    <artifactId>binding-parent</artifactId>
    <version>3.0.10</version>
    <relativePath/>
  </parent>

  <groupId>company.group</groupId>
  <version>1.0.0-SNAPSHOT</version>
  <artifactId>project-A</artifactId>
  <packaging>bundle</packaging>

  <dependencies>
    <dependency>
      <groupId>company.group</groupId>
      <artifactId>project-B</artifactId>
      <version>3.1.0-SNAPSHOT</version>
    </dependency>
    ...
  </dependencies>
</project>

Project B pom.xml

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>company.group</groupId>
    <artifactId>project-B-parent</artifactId>
    <version>3.1.0-SNAPSHOT</version>
  </parent>

  <groupId>company.group</groupId>
  <artifactId>project-B</artifactId>
  <version>3.1.0-SNAPSHOT</version>
  <packaging>bundle</packaging>

  <dependencies>
     ...
  <dependencies>
</project>

Upvotes: 2

Views: 1970

Answers (2)

Vivek
Vivek

Reputation: 436

Try below maven command for loading all updated libraries,

mvn clean install -U

Upvotes: 0

Maxdola
Maxdola

Reputation: 1650

Since you are using IntelliJ in the right upper corner there is this maven menu, where you can reimport all dependencies which helps me in this case :)

Since you are using IntelliJ in the right upper corner there is this maven menue, where you can reimport all dependencies which helps me in this case :=

Upvotes: 2

Related Questions