[英]Unable to decrypt gpg passphrase with org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign
[英]How to ignore errors of Apache Maven GPG Plugin
我正在使用Apache Maven GPG插件maven-gpg-plugin生成所需的簽名,以通過OSSRH在Maven Central中發布。 我在pom.xml上的插件定義如下,我的OSSRH憑據位於Maven conf / settings.xml,一切正常。 但是,當另一個開發人員嘗試mvn install
,對他來說失敗了,因為他沒有安裝GPG。 我想避免需要由開發人員進行部署的GPG的安裝,這可能是通過忽略構建期間的maven-gpg-plugin錯誤或其他任何方式,因此我不需要兩個pom.xml一起使用-in,另一個沒有它。
<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>
<configuration>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.passphrase}</passphraseServerId>
</configuration>
</execution>
</executions>
</plugin>
您可以將配置文件添加到pom並在其中定義maven-gpg-plugin的執行:
<project>
...
<profiles>
<profile>
<id>sign</id>
<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>
<configuration>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.passphrase}</passphraseServerId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
然后,僅在配置文件處於活動狀態時,此插件才會添加到構建過程中。 您可以通過調用Maven來激活配置文件,如下所示:
mvn install -P sign
除了手動激活配置文件外,還可以根據條件(例如環境變量或特定文件的存在)自動激活配置文件。 您可以在Maven配置文件簡介中找到有關此信息的更多信息。
在您的情況下,如果找到了特定於GPG的文件,一個選項可能是啟用配置文件:
<profile>
<id>sign</id>
<activation>
<file>
<exists>${user.home}/.gnupg/secring.gpg</exists>
</file>
</activation>
...
</profile>
我沒有測試上面的代碼,您需要檢查的實際文件可能會因所使用的GPG版本和系統環境而異。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.