Domanda

I'm using version 2.1 of the versions-maven-plugin.

I have a source tree like the following:

+-- JavaProjects
    +-- customs-deployment-support
        +-- pom.xml
    +-- pom.xml     (a.k.a. base-parentpom)
+-- Projects 
    +-- customs-template
        +-- pom.xml
    +-- customs-ear-template
        +-- pom.xml
    +-- customs-rpm-template
        +-- pom.xml
    +-- customs-site-template
        +-- pom.xml
    +-- pom.xml     (a.k.a. customs-parentpom)

Now above, the <parent /> for the customs-template project is customs-deployment-support. The <parent /> for all the other customs-*-template projects is base-parentpom.

Note: the customs-parentpom is just an "aggregator" and is not the real parent for any customs module, but it does declare each customs-* project as a <module /> in its <modules /> section.

For SNAPSHOT version builds this works great.

Now, I want to move to versioned artifacts where each artifact's version signature is something like x.x.x_yyyyMMddhhmm_nn.

So, now I want to employ the versions-maven-plugin to build the customs-parentpom (or "aggregator" pom.xml)

I use Jenkins for builds. So I configure a pre-step to jigger the versions within the <parent /> section of each customs project with something like:

mvn versions:update-parent

I want it to find the latest upstream artifacts (i.e., base-parentpom and customs-parentpom) available in Nexus.

But it fails with...

[ERROR] The build could not read 4 projects -> [Help 1]
[ERROR]   
[ERROR]   The project com.etse:etse-customs-template:3.1.0-SNAPSHOT (/var/lib/jenkins/jobs/ETSE-trunk-AllCustoms/workspace/customs-template/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Failure to find com.etse:etse-customs-deployment-support:pom:3.1.0-SNAPSHOT in http://repository.jboss.org/nexus/content/groups/public-jboss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]
[ERROR]   
[ERROR]   The project com.etse:etse-customs-ear-template:3.1.0-SNAPSHOT (/var/lib/jenkins/jobs/ETSE-trunk-AllCustoms/workspace/customs-ear-template/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Failure to find com.etse:etse-parentpom:pom:3.1.0-SNAPSHOT in http://repository.jboss.org/nexus/content/groups/public-jboss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 10 -> [Help 2]
[ERROR]   
[ERROR]   The project com.etse:etse-customs-rpm-template:3.1.0-SNAPSHOT (/var/lib/jenkins/jobs/ETSE-trunk-AllCustoms/workspace/customs-rpm-template/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Failure to find com.etse:etse-parentpom:pom:3.1.0-SNAPSHOT in http://repository.jboss.org/nexus/content/groups/public-jboss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 10 -> [Help 2]
[ERROR]   
[ERROR]   The project com.etse:etse-customs-site-template:3.1.0-SNAPSHOT (/var/lib/jenkins/jobs/ETSE-trunk-AllCustoms/workspace/customs-site-template/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Failure to find com.etse:etse-parentpom:pom:3.1.0-SNAPSHOT in http://repository.jboss.org/nexus/content/groups/public-jboss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 10 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

Consider that I never want Jenkins to produce a SNAPSHOT version artifact in the above case. I realize that the SNAPSHOT is not available in the local .m2 repository. Do I (really) need one in order for the versions plugin to resolve correctly?

What am I doing wrong? Is it even possible to do what I'm trying to do? I'm willing to share pom.xml files if that will help.

È stato utile?

Soluzione

So this was just a misunderstanding on my part. If you employ a multi-module setup, you need to make sure that when you check-out your source, in order to build a module it must be able to trace its path back to a parent (via <relativePath />).

I was checking out a module, but not its parent; therefore I was getting the the non-resolvable parent POM errors.

So, in order for the reactor to do its part, you need to define all modules in the aggregator (and/or parent) pom.xml.

Then you can build a single (or multiple) modules (projects) like so

mvn clean install --projects <project1>,<project2> --amd
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top