Buffalo
Buffalo

Reputation: 4042

How to properly link two Maven projects?

I have two projects:

  1. Project-Core

  2. Project-Source

Project-Core POM.xml:

<groupId>com.company</groupId>
<artifactId>project-core</artifactId>
<packaging>jar</packaging>
<version>2.1</version>

Project-Source POM.xml:

<dependencies>
    <dependency>
        <groupId>com.company</groupId>
        <artifactId>project-core</artifactId>
        <version>2.1</version>
        <type>pom</type> (have tried leaving it out)
    </dependency>
</dependencies>

I've done mvn clean install on Project-core, which installed the artifact in the local maven repository.

I am able to CD to Project-source and use mvn clean install (this installs Project-Source in the local maven repo as well), but I'm having trouble with NetBeans not finding the classes I need (from Project-Core) inside Project-Source.

What's a proper way of linking multiple projects? Since Project-Core produces a jar and that jar is installed in the local repository, it looks logical to only have to list that jar as a dependency on my Project-Source project. Is anything else needed?

Upvotes: 0

Views: 10530

Answers (1)

Peter Svensson
Peter Svensson

Reputation: 6173

You specified that the dependency "project-core" is of type "pom", but from the declaration it has packaging "jar" ? Try:

<dependencies>
    <dependency>
        <groupId>com.company</groupId>
        <artifactId>project-core</artifactId>
        <version>2.1</version>
    </dependency>
</dependencies>

Edit:

I've created a simple test project which worked just fine to use in Netbeand 7.0.1. Take a look and see if it gives you any hints.Code snippet

Upvotes: 4

Related Questions