Bostone
Bostone

Reputation: 37144

Using Bamboo to build Subversion/Maven project that defines parent POM(s)

I have a complex project structure that goes something like this:

- root (no pom)
     - parent(parent pom.xml)
     + project A (pom.xml)
     + project B (pom.xml)
     - project C (pom.xml)
         - subproject 1 (pom.xml)
         - subproject 2 (pom.xml)
     + project N (pom.xml)

I need to build subproject 2 using Bamboo server. I use Bamboo to checkout subproject 2 code but when I run mvn install on that it fails with "Non-resolvable parent POM" message.

The build runs fine when all the code is in the single location. I don't want to checkout code on root level since there are tons of projects that I don't want to check out (in my example that would be projects A, B, N and subproject 1)

I attempted to check out code 3 times for parent, project C/pom and subproject 2 but the code is placed onto separate directories with no relation to each other so there's not much help there

P.S. I'm using no modules, though I did try it with modules and it made no difference. I'm not posting the actual POMs since these are very trivial, basically child pom has parent element and that's all relation there is.

All upstream projects are deployed to both local and remote repos

Upvotes: 2

Views: 1876

Answers (3)

stevemac
stevemac

Reputation: 2554

Each of the maven modules should be self contained, using relative links that talk about ../parent breaks this design.

Try and explicitly define the parents by GAV properties, and then ensure these poms are installed in your local maven repo and you will be able to build sub projects.

We run a 15 module build down 3 levels and this is all possible.

The only issue you have is when you bump versions, you will have to kick off an install of the root pom file to boostrap the resolution process.

Upvotes: 0

Justin Garrick
Justin Garrick

Reputation: 14947

We have a very similar project structure, and I just verified that I'm able to create a Jenkins job that only checks out the equivalent of subproject1 and builds it with mvn -U clean install. I have no access to a Bamboo instance, but both Jenkins and Bamboo just invoke Maven under the hood, so there should be no difference here.

The other option that works, as you mentioned, is to checkout the entire repository, (or directory containing root and all modules) and run mvn -U clean install -pl subproject1 -am on the parent POM.

To help you with this, we really need more information. You mentioned in one of your comments that "all [upstream] dependencies are already deployed to repo". Do you mean your local repository (i.e. .m2/repository)? You should double check that this directory contains all of the parent POMs. Are you resolving all artifacts from a proxy (i.e. Artifactory/Nexus)? If so, also check that the POMs are available there.

Your current structure diagram doesn't show the location of the POMs. I assume you've got it setup correctly, but I have seen cases where people put child modules in strange locations, which can cause problems. The relative locations of the POMs matter (unless you do some customization). Could you run tree on the root and sanitize the output so that we know exactly where your POMs are in relation to one another? For example:

parentProject
|-- projectA
|   |-- pom.xml
|
|-- projectB
|   |-- pom.xml
|   |
|   |-- subProject1
|   |   |-- pom.xml
|   |    
|   |-- subProject2
|       |-- pom.xml
|
|-- pom.xml

Lastly, could you navigate to the child project/module you're attempting to build and post the output of mvn help:effective-pom?

Upvotes: 1

sbridges
sbridges

Reputation: 25150

mvn will look for dependencies in three places, in a relative path on the local file system, cached in the m2 repo on your local machine, or in an external repo. If you install all the dependencies on a repo that bamboo can access, your build will probably work.

To test this, on your local machine, can you do a mvn install from the root directory (placing all the dependencies in the m2 repo on your machine), and then checkout subproject2 in a separate directory and then mvn install subproject2?

If that works, then the dependencies of subproject 2 need to be in a maven repo that bamboo can access. Deploy them using something like artifactory before doing mvn install with bamboo.

Upvotes: 2

Related Questions