views:

334

answers:

3

Hi,

I have two maven projects A and B, both of which I'm actively working on the source code for. Project A depends on B. If I want to build project A, does a snapshot (or release) of B need to exist in the repository? Or will maven check the parent directory of A to see if a project B exists (assuming my directory structure looks something like: projects/A projects/B)? And which would be better practice? thanks.

Jeff

+3  A: 

Maven won't look anywhere except the repository hierarchy you specify, by default this is your .m2 directory (local repository) and the Maven Central Repository.

So yes, some version of B must exist in a repository.

You can also investigate project modules, where you have (for example) projects/pom.xml and when it is built, it will also build its children A and B in the correct order given their inter-dependencies - but you shouldn't see this as a solution to the problem you're describing without giving a lot of thought.

Cogsy
The m2 eclipse plugin will also look in the workspace.
Jeff Storey
A: 

To get a good grasp on how the Dependency Mechanism works in maven and how to configure parent-child/submodule/subproject relations read this

jitter
A: 

Maven is a strange build tool in that it will look to the maven repository / artifactory for jars. As long as someone has built ProjectB and installed it in the artifactory, or as long as you have built ProjectB (with install) it will be available to ProjectA.

This also assumes you have setup the dependancy correctly in the pom file for ProjectA.

I used Maven on one project, and I'll go back to ant for a more standard build tool. It's really an odd duck.

Kieveli