【问题标题】:Maven release:perform without deploy and calling an external shell scriptMaven 发布:无需部署和调用外部 shell 脚本即可执行
【发布时间】:2011-03-27 13:58:10
【问题描述】:

我正在使用 Maven 发布插件。问题很简单:我不想在发布时进行部署:执行。我实际上想执行一个 shell 脚本来为我进行部署。所以我有两件事要完成:

  1. 以某种方式禁用 release:perform 中的默认“部署”目标

  2. 以某种方式 make release:perform 调用 exec:exec 插件来执行 shell 脚本

这是我的 pom:

<plugin>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <tagBase>svn://saoj-la.dyndns.org/webapp-test/tags</tagBase>
        <connectionUrl>scm:svn:svn://saoj-la.dyndns.org/webapp-test/trunk</connectionUrl>
    </configuration>
</plugin>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>/bin/sh</executable>
        <arguments>
            <argument>run.sh</argument>
        </arguments>
    </configuration>
</plugin>

【问题讨论】:

    标签: maven-2 maven-release-plugin


    【解决方案1】:

    有点晚了,仅供参考:

    对于您的第 1 步,您可以使用“跳过”选项禁用 Maven 部署步骤。点击here参考。

    在命令行上,你可以调用类似:

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

    【讨论】:

    • 我的用例:将 SVN 存储库迁移到 Git,并希望在我的 pom.xml 中验证 SCM url。运行 mvn release:prepare; mvn release:perform -Darguments="-Dmaven.deploy.skip=true" 允许我在我的 fork 中发布假版本,而不是将假工件推送到工件
    【解决方案2】:

    我正在使用 Maven 发布插件。问题很简单:我不想在发布时进行部署:执行。我实际上想执行一个 shell 脚本来为我进行部署。

    我一定是遗漏了什么,因为当我读到这篇文章时,我看不出剧本的意义……但我们只能说我不明白。

    以某种方式禁用 release:perform 中的默认“部署”目标

    根据release:perform的文档,可以使用可选的goals参数来指定:

    在部署时执行的目标的空格分隔列表。如果项目具有&lt;distributionManagement&gt;/&lt;site&gt; 元素,则默认值为deploydeploy site-deploy

    您可以使用install 代替deploy

    以某种方式 make release:perform 调用 exec:exec 插件来执行一个 shell 脚本

    在发布期间激活的配置文件中将其绑定到install。这是执行此操作的一种方法:

    <profile>
      <!-- Profile used when the release plugin executes. -->
      <id>release</id>
      <activation>
        <property>
          <!-- This property is automatically defined by the Maven release plugin when executing
               a release. Thus this profile will be automatically enabled when releasing -->
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        ...
      </build>
    </profile>
    

    但老实说,您的请求有些奇怪。也许提供更多细节会有所帮助。

    【讨论】:

    • 使用 install 将“部署”切换到“安装”任务。谢谢。这样做就足够了:install exec:exec 但 release:perform 不喜欢 exec:exec:stackoverflow.com/questions/3445396/…
    • @Sergio 好吧,这不是我的建议,我不确定这是否可行。
    • 嘿帕斯卡。你的建议也不起作用。因为 release:perform 分叉了另一个进程,所以配置文件没有被激活。另一个问题是 标签,因为 release:perform 是一个目标,而不是一个阶段。无论如何:我的解决方案是强制用户在 release:perform 之后手动调用 exec:exec。在 release:perform 之后级联 exec:exec 没有简单的方法。我不喜欢Maven的是这个。简单的事情变得异常困难。使用 ant,您可以完成任何您想做的事情。不是说ANT更好,只是尊重KISS原则。
    • @Sergio Weird,个人资料确实对我有用。其次,我明确写信尝试绑定install 阶段,而不是release:perform。第三,我不想讨论 KISS 的事情(这可能值得商榷,但你的用例看起来不像 KISS)但是如果 Maven 不能像你想要的那样工作,我的建议是不要使用它。
    • @Sergio 在 MAC 上应该不是问题,至少在理论上是这样。而且我无法轻松测试您的场景,因此恐怕无法提供进一步的帮助(我仍然认为在配置文件中的某个阶段绑定 exec:exec 是可行的方法)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-16
    • 2011-04-26
    • 2017-06-24
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多