2

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>
jvhashe
  • 1,071
  • 2
  • 12
  • 15

2 Answers2

2

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 :=

Maxdola
  • 1,562
  • 2
  • 10
  • 29
  • Yeah, I was using that. Doesn't help at all though. – jvhashe Jan 10 '20 at 01:01
  • I guess you've restarted IntelliJ ? And when thats the case, I have no concreat idea. The only difference to me is I am building both in IntelliJ and none with the CLI and I also use `clean`. – Maxdola Jan 10 '20 at 01:04
0

Try below maven command for loading all updated libraries,

mvn clean install -U

Vivek
  • 376
  • 1
  • 14
  • This forces an update from the remote repository, which I want to avoid. I want to use the locally built version of the jar. – jvhashe Jan 13 '20 at 19:06
  • Try https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project – Vivek Jan 14 '20 at 05:35