当我和我的团队必须将新的 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/