3

I have a classical multimodule project with cross dependency

parent pom:

<modules>
    <module>mod1</module>
    <module>mod2</module>
</modules>
...
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>grp</groupId>
            <artifactId>mod1</artifactId>
            <version>${project.version}</version>
        </dependency>
...

mod2 pom:

<dependencies>
    <dependency>
      <groupId>grp</groupId>
      <artifactId>mod1</artifactId>
    </dependency>
 ...

It builds mvn clean install fine, however when CI runs sonar using mvn sonar:sonar ... the maven tries to download mod1 snapshot dependency from repo, which supposed to be part of the same reactor.

Downloading from nexus: http://...mod1/1.0.0-SNAPSHOT/maven-metadata.xml

And it most cases it could not find the snapshot as it was not deployed yet, but it just keeps going. However it slows down the build as I have several modules and each takes a while to make a roundtrip to repository.

Why?

kan
  • 28,279
  • 7
  • 71
  • 101

1 Answers1

0

I had a very similar problem: mvn install was working fine, mvn sonar:sonar wasn't.

In my case, it was a test dependency:

<dependency>
  <groupId>grp</groupId>
  <artifactId>mod2</artifactId>
  <version>${project.version}</version>
  <type>test-jar</type>
  <scope>test</scope>
</dependency>

It was solved by adding test-compile to the mvn command:

mvn test-compile sonar:sonar

I got the tip from this answer: https://stackoverflow.com/a/57226037/5269825

I guess maven needs something (like compile or compile-test) to know that the dependency is another submodule.

Matruskan
  • 325
  • 3
  • 11