1. Problem description
The jar is released here, using the maven-gpg-plugin plug-in, and using the command line to execute the command:
mvn gpg:sign-and-deploy-file -Durl=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=xxx-common-1.0.2.pom -Dfile=xxx-common-1.0.2.jar
Compatibility error reported:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-gpg-plugin:3.0.1:sign-and-deploy-file (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.462 s
[INFO] Finished at: 2022-03-13T07:47:25+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign-and-deploy-file (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign-and-deploy-file failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign-and-deploy-file: java.lang.AbstractMethodError: org.apache.maven.plugins.gpg.SignAndDeployFileMojo$SimpleModelProblemCollector.add(Lorg/apache/maven/model/building/ModelProblemCollectorRequest;)V
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-gpg-plugin:3.0.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/E:/mavenRepository/org/apache/maven/plugins/maven-gpg-plugin/3.0.1/maven-gpg-plugin-3.0.1.jar
[ERROR] urls[1] = file:/E:/mavenRepository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[2] = file:/E:/mavenRepository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[3] = file:/E:/mavenRepository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] urls[4] = file:/E:/mavenRepository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[5] = file:/E:/mavenRepository/org/codehaus/plexus/plexus-component-annotations/2.0.0/plexus-component-annotations-2.0.0.jar
[ERROR] urls[6] = file:/E:/mavenRepository/org/apache/maven/shared/maven-artifact-transfer/0.12.0/maven-artifact-transfer-0.12.0.jar
[ERROR] urls[7] = file:/E:/mavenRepository/org/apache/maven/shared/maven-common-artifact-filters/3.0.1/maven-common-artifact-filters-3.0.1.jar
[ERROR] urls[8] = file:/E:/mavenRepository/org/apache/maven/shared/maven-shared-utils/3.1.0/maven-shared-utils-3.1.0.jar
[ERROR] urls[9] = file:/E:/mavenRepository/commons-io/commons-io/2.5/commons-io-2.5.jar
[ERROR] urls[10] = file:/E:/mavenRepository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
[ERROR] urls[11] = file:/E:/mavenRepository/org/codehaus/plexus/plexus-utils/3.3.0/plexus-utils-3.3.0.jar
[ERROR] urls[12] = file:/E:/mavenRepository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[13] = file:/E:/mavenRepository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
I specified the version number in the pom.xml file, but it did not take effect
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Two, the solution
The configuration in the pom.xml file does not take effect, only the default plug-in version number of maven can be changed, and the version number can be specified in the following format:
mvn groupID:artifactID:version:goal
It can be executed by modifying it as follows
mvn org.apache.maven.plugins:maven-gpg-plugin:1.5:sign-and-deploy-file -Durl=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=xxx-common-1.0.2.pom -Dfile=xxx-common-1.0.2.jar