代码之家  ›  专栏  ›  技术社区  ›  YuppieNetworking

带有依赖于配置文件的子模块的Maven发布插件

  •  1
  • YuppieNetworking  · 技术社区  · 15 年前

    我正在尝试使用一个多模块maven项目执行一个发布。我的目标是修改所有poms的版本,并在SCM中创建一个标记,这就是我使用maven发布插件的原因。

    example/
        module1/
        module2/
            module-jni-linux/
            module-jni-macosx/
    

    的pom.xml example

    <modules>
      <module>module1</module>
      <module>module2</module>
    </modules>
    

    以及的pom.xml module2 包含依赖于由操作系统类型确定的配置文件的模块:

    <profiles>
    <!-- profile for linux -->
    <profile>
      <id>linux</id>
      <activation>
        <os>
          <name>linux</name>
        </os>
      </activation>
      <modules>
        <module>module-jni-linux</module>
      </modules>
    </profile>
    <!-- profile for mac os -->    
    <profile> 
      <id>macosx</id>
      <activation>
        <os>
          <name>mac os x</name>
        </os>
      </activation>
      <modules> 
        <module>module-jni-macosx</module> 
      </modules> 
    </profile> 
    

    最后,每个 module-jni-* 使用本地Maven插件编译一些C/C++源,并生成共享库。


    问题是:

    mvn release:prepare -DdryRun=true 在MacOSX中,我意识到 module-jni-linux 在发布过程中没有考虑到。这意味着当所有模块都传递到1.0.0/1.0.1快照版本时, 未修改。我想做什么 release:prepare 即使其配置文件尚未激活,也会更新所有子模块。

    我试着用 mvn -P linux,macosx ... jni linux模块 不会在mac(和viceversa)下构建。

    如何执行更新两个子模块版本的版本?

    2 回复  |  直到 15 年前
        1
  •  1
  •   YuppieNetworking    15 年前

    好吧,我找到了一个办法:

    为了创建一个版本,maven版本插件运行 clean verify 在提交给供应链管理之前的目标。这个 验证

    我现在要做的是配置插件,以便它只运行 验证 目标。但是自从 验证

    1. 运行 mvn clean verify 在Mac和Linux环境中。为此,我配置了一个多节点hudson作业。
    2. mvn release:prepare -P macosx,linux -DdryRun=true -DpreparationGoals=clean ,这将激活两个配置文件,但跳过编译
    3. 检查干运行结果是否令人满意
    4. 使用执行步骤2 -DdryRun=false
        2
  •  0
  •   jgifford25    15 年前

    对于父pom.xml中的Maven发行版插件配置,是否尝试使用 <arguments> 指定要启用的配置文件的参数?

    您可以在这里阅读更多信息: http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html

    推荐文章