Maven发布:无需部署和调用外部shell脚本即可执行

发布于 2024-09-13 13:28:13 字数 1174 浏览 7 评论 0原文

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

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

  2. 以某种方式使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>

I am using the maven release plugin. Problem is simple: I don't want to do a deploy on release:perform. I actually want to execute a shell script that will do the deploy for me. So I have two things to accomplish:

  1. Somehow disable the default "deploy" goal from release:perform

  2. Somehow make release:perform call the exec:exec plugin to execute a shell script

Here is my 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花海 2024-09-20 13:28:13

有点晚了,但仅供参考:

对于步骤 1,您可以使用“跳过”选项禁用 Maven 部署步骤。单击此处以供参考。

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

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

A little late, but for reference:

For your step 1, you can disable the maven deploy step by using the "skip" option. Click here for reference.

On the commandline you could call something like:

mvn release:perform -Darguments="-Dmaven.deploy.skip=true"
被你宠の有点坏 2024-09-20 13:28:13

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

我一定错过了一些东西,因为当我读到这篇文章时,我没有看到剧本的重点……但我们只能说我不明白。

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

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

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

您也许可以使用install 而不是deploy

以某种方式让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>

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

I am using the maven release plugin. Problem is simple: I don't want to do a deploy on release:perform. I actually want to execute a shell script that will do the deploy for me.

I must be missing something because when I read this, I don't see the point of the script... But let's just say I don't get it.

Somehow disable the default "deploy" goal from release:perform

According to the documentation of release:perform, you can use the optional goals parameter to specify:

A space separated list of goals to execute on deployment. Default value is either deploy or deploy site-deploy, if the project has a <distributionManagement>/<site> element.

You could maybe use install instead of deploy.

Somehow make release:perform call the exec:exec plugin to execute a shell script

Bind it on install in a profile activated during release. Here is one way to do this:

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

But honestly, there is something weird with your request. Maybe giving more details would help.

眉目亦如画i 2024-09-20 13:28:13

如果您不想每次运行命令 mvn release:perform 时都输入 -Darguments="-Dmaven.deploy.skip=true" ,您可以在 中配置skip >pom.xml

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

If you do not want to type -Darguments="-Dmaven.deploy.skip=true" everytime you run the command mvn release:perform you can configure skip inside pom.xml

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>XXX</version>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
  </plugins>
</build>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文