How can I make one Maven module depend on another?

Posted by Daniel Pryden on Stack Overflow See other posts from Stack Overflow or by Daniel Pryden
Published on 2010-03-24T22:30:44Z Indexed on 2010/03/24 22:33 UTC
Read the original article Hit count: 199

Filed under:
|
|

OK, I thought I understood how to use Maven...

I have a master project M which has sub-projects A, B, and C. C contains some common functionality (interfaces mainly) which is needed by A and B. I can run mvn compile jar:jar from the project root directory (the M directory) and get JAR files A.jar, B.jar, and C.jar. (The versions for all these artifacts are currently 2.0-SNAPSHOT.)

The master pom.xml file in the M directory lists C under its <dependencyManagement> tag, so that A and B can reference C by just including a reference, like so:

<dependency>
    <groupId>my.project</groupId>
    <artifactId>C</artifactId>
</dependency>

So far, so good. I can run mvn compile from the command line and everything works fine. But when I open the project in NetBeans, it complains with the problem: "Some dependency artifacts are not in the local repository", and it says the missing artifact is C. Likewise from the command line, if I change into the A or B directories and try to run mvn compile I get "Build Error: Failed to resolve artifact."

I expect I could manually go to where my C.jar was built and run mvn install:install-file, but I'd rather find a solution that enables me to just work directly in NetBeans (and/or in Eclipse using m2eclipse).

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about maven-2

Related posts about netbeans