如何使Maven Versions插件更新 - 父目标与多模块项目一起工作

时间:2013-10-07 23:44:42

标签: java maven-3 parent multi-module versions-maven-plugin

我正在使用2.1的版本versions-maven-plugin

我有一个如下所示的源代码树:

+-- 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)

如上所述,<parent />项目的customs-templatecustoms-deployment-support。所有其他<parent />项目的customs-*-templatebase-parentpom

注意:customs-parentpom只是一个“聚合器”,并不是任何海关模块的真正父项,但它确实将customs-*个项目声明为<module /> <modules /> 1}}部分。

对于SNAPSHOT版本的构建,这非常有用。

现在,我想转移到versioned个工件,其中每个工件的版本签名都类似于x.x.x_yyyyMMddhhmm_nn

所以,现在我想使用versions-maven-plugin来构建customs-parentpom(或“聚合器”pom.xml

我使用Jenkins进行构建。因此,我配置了一个前步骤,以便在每个海关项目的<parent />部分中使用类似的东西进行跳汰:

mvn versions:update-parent

我希望它能找到Nexus中可用的最新上游工件(即base-parentpomcustoms-parentpom)。

但它失败了......

[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

考虑到我绝不希望Jenkins在上述情况下生成SNAPSHOT版本工件。我意识到SNAPSHOT在本地.m2存储库中不可用。我(真的)需要一个版本插件才能正确解析吗?

我做错了什么?是否有可能做我想做的事情?如果有帮助,我愿意分享pom.xml文件。

1 个答案:

答案 0 :(得分:0)

所以这只是我的一个误解。如果您使用多模块设置,则需要确保在签出源代码时,为了构建模块,它必须能够将其路径追溯到parent(通过{{1 }})。

我正在检查一个模块,但不是它的父项;因此我得到了<relativePath />错误。

因此,为了让reactor发挥作用,您需要在聚合器(和/或父代)non-resolvable parent POM中定义所有模块。

然后你可以构建一个(或多个)模块(项目),如此

pom.xml