Search code examples
eclipsemavenm2eclipse

Eclipse M2E Plugin don't add dependency from same workspace


I have two maven projects:

Project-A: Generating code via a tool

Projects-B: This project depends on project-A, because it uses the generated code.

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/xsd/maven-4.0.0.xsd">
....
<dependencies>
    <dependency>
        <!-- This is project-A -->
        <groupId>de.hsas.thrift</groupId>
        <artifactId>tutorial</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>
</project>

project-B/Maven-Dependencies in Eclipse

Here is not the tutorial-SNAPSHOT.jar included, but a ?reference? to the project-A?

How can i solve this behavior? I want that there is the jar of project-A.

I tried something like this:

  <dependencies>
    <dependency>
        <groupId>de.hsas.thrift</groupId>
        <artifactId>tutorial</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <scope>system</scope>
        <systemPath>${env.HOME}/.m2/repository/de/hsas/thrift/tutorial/0.0.1-SNAPSHOT/tutorial-0.0.1-SNAPSHOT.jar</systemPath>
    </dependency>
</dependencies>

But this seems like to be not convenient..


Solution

  • Right-clicking your Maven project in one of Eclipse's Explorers → Properties...Maven → ☐ Resolve dependencies from Workspace projects should do the trick.

    See also Developing with Eclipse and Maven, 8.1.3. Resolving Dependencies.