java - 仅在生产中签署 Maven Artifact 的最佳做法是什么?

标签 java maven release gnupg maven-central

当我和我的团队必须将新的 Maven Artifact 发布推送到中央时,我们使用的过程是:

mvn release:clean
mvn release:prepare
mvn release:perform

一切正常。

当然,pom.xml 包含对 maven gpg 插件的引用以密封 jars:

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

或者 mvn release:perform 失败:

但是在开发过程中,我们中的一些人没有/不能安装 gpg.exe 程序或签名 key (只有主开发人员有正确的密封最终 jar 的 key ) .

因此,如果我们在本地执行 mvn clean install 或其他类型的命令,该过程将失败,并且我们无法在开发时将本地修改的 jar 放入 .m2 文件夹中。

只有在执行命令 mvn release:perform 时才执行 che 包签名的最佳做法是什么?

最佳答案

发布并签署 Artifact 已经解决。您可以使用将激活标志插件的配置文件。更多详细信息和背后的故事将在这里找到https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ .

<profiles>
  <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
  </profile>
</profiles>

关于java - 仅在生产中签署 Maven Artifact 的最佳做法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56726920/

相关文章:

java - 定期发送大量邮件

r - alpha、beta、开发和修补版本(例如 R)之间的差异?

java - 如何将 ExpandableListView 的选定项目存储在 ArrayList 中

java - Java中的自动内存泄漏检测

java - 使用 List 成员序列化对象

java - Maven 程序集 jar 中的 Datanucleus JDO

java - Tomcat - Eclipse 中的服务器

maven - Spring - 上下文初始化失败

c++ - 我如何使用 DEV C++ 构建发布 exe?

svn - 探索新的版本控制系统。我最大的需要: Reliable merging