1. 下载maven到指定目录,指定对应的gpg的执行命令所需要的属性。这里比如下载解压后的maven目录是: C:maven-apache-3.3.2 ,那么配置文件目录是: C:maven-apache-3.3.2confsettings.xml
<profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>the_pass_phrase</gpg.passphrase> </properties> </profile> </profiles>
2. 在maven的pom.xml文件中配置运行的maven插件.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> <version>${maven-gpg-plugin.version}</version> <executions> <execution> <id>sign-artifacts</id> <phase>verify</phase> <goals> <goal>sign</goal> </goals> <!-- <configuration> <executable>gpg</executable> <homedir>${gpg.homedir}</homedir> <keyname>${gpg.keyname}</keyname> <passphrase>${gpg.passphrase}</passphrase> </configuration> --> </execution> </executions> </plugin>