【问题标题】:Maven Release: How to skip deploy step?Maven 发布:如何跳过部署步骤?
【发布时间】:2020-01-26 08:17:04
【问题描述】:

为了发布我的应用,我使用 ma​​ven-release-plugin

此过程的一个步骤是将版本部署到存储库中。 我想避免这一步,但是当我从我的 pom 文件中删除 distributionManagement 时,我收到了错误:

Deployment failed: repository element was not specified in the POM inside distributionManagement element 

如何配置 maven-release-plugin 跳过部署?

感谢您的建议!

【问题讨论】:

  • 为什么要避免这种情况?您没有使用存储库吗?
  • 插件会为我做几件事,例如:增加版本,在git repo中创建一个标签等。所有这些都非常有用,但我真的不需要部署jar对于每个版本。可能听起来很有趣,但我确实经常发布(一天几次)而且我在 VPS 上没有那么多空间:)。如果以后需要获取旧版本,我可以签出标签并构建它。

标签: maven maven-release-plugin


【解决方案1】:

每天发布几次这并不奇怪或有趣。空间问题可能值得商榷,但这是一个单独的讨论。

您可以配置maven release plugin在发布期间会完成什么样的目标。这最多可以通过在 pluginManagement 中配置插件来实现。而且你应该定义你正在使用的所有插件的所有版本(大多数时候为你的环境创建一个父 pom 是最方便的)。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <configuration>
    <arguments>${arguments}</arguments>
    <goals>The Goal You would like to execute</goals>
    <autoVersionSubmodules>true</autoVersionSubmodules>
  </configuration>
</plugin>

所以你可以定义为只制作install 而不是像这样部署:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <configuration>
    <arguments>${arguments}</arguments>
    <goals>install</goals>
    <autoVersionSubmodules>true</autoVersionSubmodules>
  </configuration>
</plugin>

【讨论】:

    【解决方案2】:

    作为mentioned here,你可以使用:

    mvn release:perform -Darguments="-Dmaven.deploy.skip=true"
    

    (也可以在其他插件上使用,例如github-release-plugin

    glib-briia/cucumber-jvm-scala pom.xml 所示,您还可以在 pom.xml 中定义配置文件,以便在需要时激活 skip

    【讨论】:

    • 只有在你的层次结构中相应地配置了 maven-release-plugin 时,参数才会起作用。除此之外,如果您必须多次这样做,您可能会错过参数并使其比必要的更不方便。
    • 配置文件意味着您必须将选项添加到命令行,这不是很方便...
    猜你喜欢
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 2018-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-20
    相关资源
    最近更新 更多