【问题标题】:How to disable nexus-staging-maven-plugin in sub-modules如何在子模块中禁用 nexus-staging-maven-plugin
【发布时间】:2014-10-07 23:24:03
【问题描述】:

我正在考虑用 nexus-staging-maven-plugin 替换 maven-deploy-plugin。

现在我的项目的一些子模块(例如集成测试模块)不会部署到 Nexus 服务器。我曾经通过“maven.deploy.skip”属性禁用这些模块的部署。不过,我找不到任何可与 nexus-staging-maven-plugin 相媲美的东西。是否有其他方法可以使用此插件从部署中跳过单个模块?

我还尝试将插件绑定到伪阶段“无”,如here 所述,但检查有效 POM,仍然存在插件的注入执行(我认为这是由于方式它如何替换现有的部署插件)。

【问题讨论】:

    标签: maven nexus


    【解决方案1】:

    您可以将给定子模块的配置属性skipNexusStagingDeployMojo 设置为true。查看the Nexus book chapter about deployment to staging 中记录的更多配置属性。

    【讨论】:

    • 这样,如果反应堆中的最后一个模块/子模块被跳过,工件将根本不会被部署。无论如何都没有找到告诉nexus-staging-maven-plugin部署它的方法。有什么提示吗?我确实想跳过部署两个仅带有示例的子模块(仅作为源可见)。
    • 只需在要跳过的模块中设置配置参数,而不是在父模块中..
    • 这正是我所做的。没有成功。
    • 这方面有什么进展吗?我有同样的问题,所有模块都被跳过。这是我的项目github.com/AKSW/RDFUnit
    • 这是一个 sonatype 错误,详情见这里issues.sonatype.org/browse/NEXUS-9138
    【解决方案2】:

    面临类似的问题。对我有用的解决方案是在需要从部署任务中排除的模块中添加跳过为 true 的部署插件。

               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-deploy-plugin</artifactId>
                  <configuration>
                    <skip>true</skip>
                  </configuration>
                </plugin>
    

    【讨论】:

      【解决方案3】:

      我发现解决 nexus-staging-maven-plugin 限制的最简单方法是将您不想部署的任何模块隔离到单独的 Maven 配置文件中,并在部署发生时将其排除。示例:

      <profile>
          <id>no-deploy</id>
          <!--
          According to https://github.com/sonatype/nexus-maven-plugins/tree/master/staging/maven-plugin
          skipNexusStagingDeployMojo may not be set to true in the last reactor module. Because we don't
          want to deploy our last module, nor a dummy module, we simply omit the relevant modules when
          a deploy is in progress.
          -->
          <activation>
              <property>
                  <name>!deploy</name>
              </property>
          </activation>
          <modules>
              <module>test</module>
              <module>benchmark</module>
          </modules>
      </profile>
      

      在上面的示例中,我避免构建和部署“测试”和“基准”模块。如果您想在不部署它们的情况下运行单元测试,请使用单独的运行:

      mvn test
      mvn -Ddeploy deploy
      

      【讨论】:

      • 您的意思是“-Pdeploy”吗?根据maven.apache.org/guides/introduction/…,您可以使用“-P”标志激活配置文件
      • @BenMcCann 不,我的意思是-Ddeploy。您可以按照您的建议使用-Pno-deploy,但是在我的项目中,我想在deploy 为真时激活一个配置文件,而在deploy 为假时激活另一个项目。使用-Pdeploy-Pno-deploy 会起作用,但对我来说似乎是不必要的冗长。不过,这两种方法都是有效的。
      猜你喜欢
      • 2018-11-03
      • 2014-06-03
      • 2014-12-20
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 2013-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多