在部署到远程仓库之前运行Maven插件 [英] Run Maven plugin just before deploy to remote repo

查看:85
本文介绍了在部署到远程仓库之前运行Maven插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Maven项目中,我使用pgp插件对我的jar进行签名.我仅在部署到远程仓库时才需要这样做,而在安装到本地仓库时就不需要这样做.因此,我尝试设置部署阶段.

In my maven project I use the pgp plugin to sign my jars. I need to do this only when deploying to remote repo, but not when installing to local repo. So I tried to set the phase to deploy.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>sign-artifacts</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

通过该配置,maven首先部署到远程仓库,然后在我的jar上签名...

With that configuration maven first deploys to remote repo and theh signs my jars...

我了解到插件是按照在POM文件中定义的顺序执行的,因此我尝试在sign插件之后配置deploy-plugin,但这没有任何作用

I read that plugins are executed in the order they are defined in POM file, so I tried to configure deploy-plugin after sign plugin, but that didnt have any effect

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>sign-artifacts</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.8.2</version>
            <executions>
                <execution>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我如何实现在上载工件之前在安装时不执行sign插件,而是在部署时执行?我正在使用maven3.

How can I achieve that sign plugin is not executed on install, but on deploy before artifacts are uploaded? I'm using maven3.

推荐答案

首先,我建议更新绑定maven-deploy-plugin 作为deploy生命周期,对于 maven-gpg-plugin verify生命周期阶段,如果您有集成测试,那将是不理想的.在这种情况下,定义一个仅在发布情况下被激活的配置文件是有意义的,以防止与集成测试相混淆.

First i would suggest to update maven-gpg-plugin to an more up-to-date version cause this version 1.1 is of 2010..Apart from that i would suggest to keep the defaults of the plugins which means the binding of maven-deploy-plugin as the deploy life cycle and for the maven-gpg-plugin the verify life cycle phase which is not ideal if you have integration tests. In such cases it makes sense to define a profile which is activated only in release cases to prevent confusions with integration test.

<plugin>
  <inherited>true</inherited>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>2.8.2</version>
  <configuration>
    <updateReleaseInfo>true</updateReleaseInfo>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>deploy</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-gpg-plugin</artifactId>
  <version>1.6</version>
  <executions>
    <execution>
      <id>sign-artifacts</id>
      <goals>
        <goal>sign</goal>
      </goals>
    </execution>
  </executions>
</plugin>

这篇关于在部署到远程仓库之前运行Maven插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆