【问题标题】:How to make Maven Versions Plugin update-parent goal work with multi-module project如何使 Maven 版本插件更新父目标与多模块项目一起使用
【发布时间】:2013-10-14 17:26:23
【问题描述】:

我使用的是versions-maven-plugin2.1 版本。

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

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

现在上面,customs-template 项目的<parent />customs-deployment-support。所有其他customs-*-template 项目的<parent />base-parentpom

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

对于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 文件。

【问题讨论】:

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


    【解决方案1】:

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

    我正在检查一个模块,但不是它的父模块;因此我得到了non-resolvable parent POM 错误。

    因此,为了让反应器发挥作用,您需要在聚合器(和/或父级)pom.xml 中定义所有模块。

    然后你可以像这样构建单个(或多个)模块(项目)

    mvn clean install --projects <project1>,<project2> --amd
    

    【讨论】:

    • 您是如何处理发布项目的情况的(例如:custom-ear-template,假设其父级是 JavaProjects 中的项目之一)。假设当前 JavaProjects 版本是 0.0.4-SNAPSHOT 并且在 custom-ear-template 中你想获得 0.0.1 版本,我不认为使用版本:update-parent 将适用于项目的 0.0.1 版本(因为它'将构建一个 0.0.3 的 custom-ear-template 工件,而不是构建一个 0.0.1 的发布工件 jar/war 等文件)。 stackoverflow.com/questions/25918593/…
    猜你喜欢
    • 2018-02-13
    • 2017-01-19
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 2011-08-09
    • 1970-01-01
    • 2014-07-27
    • 2014-03-28
    相关资源
    最近更新 更多