Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ 12 - maven multimodule cannot resolve transitive dependencies

I've imported maven multimodule project and some transitive dependencies are not resolved. This same project builds in Jenkins/Eclipse/Console.

I've tried two import each project separately, and also to import only parent pom - both are not working.

I have following structure: Project A and Project B have common parent and both are defined as modules in this parent. Project A contains as dependency jackon-jar, Project B does not have it. Project A contains jackson-jar in default scope - jar is visible during compilation and tests are running. Now Project B imports Project A and also uses jackson-jar - and here is the problem - jackson-jar in not visible in Project B :( When I specify it explicitly in Project B all works fine, but it should come automatically as transitive dependency from Project A ......

Is this common problem? Is there workaround?

Here are POM examples:

Parent:

<project ....>
    <modelVersion>4.0.0</modelVersion>

    <version>1.0-SNAPSHOT</version>
    <groupId>miklas.test</groupId>
    <artifactId>my-parent</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>my-project-a</module>
        <module>my-project-b</module>
        <module>my-project-c</module>
    </modules>
</project>

Project-A

<project ....>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>miklas.test</groupId>
        <artifactId>my-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>my-project-a</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>2.3.4.Final</version>
        </dependency>
    </dependencies>

</project>

Project-B

<project >
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>miklas.test</groupId>
        <artifactId>my-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>my-project-b</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>miklas.test</groupId>
            <artifactId>my-project-a</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

</project>

Below is also the screenshot from my real project - this would be Project B from simplified example above. On the left side we can see, that resteasy-jackoson-provider has 4 dependent jars, and on the right side there are only two. Both views are showing the same project:

enter image description here

Now the same screenshot from Project A

enter image description here

like image 496
Maciej Miklas Avatar asked Jan 03 '13 09:01

Maciej Miklas


People also ask

How does Maven resolve transitive dependencies?

Transitive Dependencies. Maven avoids the need to discover and specify the libraries that your own dependencies require by including transitive dependencies automatically. This feature is facilitated by reading the project files of your dependencies from the remote repositories specified.

How do you fix transitive dependency?

Once you identify your package to be fixed using any of the above methods, to fix the transitive dependency, you must add a dependency to the updated version of the vulnerable package by adding it to the . csproj file. i.e such a vulnerable package needs to be made a direct dependency of your main project.


1 Answers

This appears to be a bug in IntelliJ 12. See http://youtrack.jetbrains.com/issue/IDEA-98425 and please vote for the issue if it's important to you.

like image 133
Anonymoose Avatar answered Sep 28 '22 12:09

Anonymoose