I want to publish my local library to the Maven Repository. One step in their documentation is to add
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
to the pom file. This obviosly requires having gpg set up. I already have Kleopatra set up and can run gpg commands in my command line.
gpg --version
gpg (GnuPG) 2.4.3
gpg is also added to the system Path.
But when running mvn clean deploy, I get
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign (sign-artifacts) on project ownDependency: Execution sign-artifacts of goal org.apache.maven.plugins :maven-gpg-plugin:3.0.1:sign failed: Cannot invoke "org.apache.maven.plugins.gpg.GpgVersion.toString()" because "gpgVersion" is null
I added antrun to see if Maven can execute gpg commands
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>run-gpg-command</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="gpg" failonerror="true">
<arg value="--version"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
an it succesfully prints
[INFO] --- antrun:3.0.0:run (run-gpg-command) @ project---
[INFO] Executing tasks
[INFO] [exec] gpg (GnuPG) 2.4.3
Just in case that this could be related to the settings.xml file, as explained in the documentation, I added
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg2</gpg.executable>
<gpg.passphrase>passphrase</gpg.passphrase>
</properties>
</profile>
and
<server>
<id>ossrh</id>
<username>fgutzy</username>
<password>s&N8CI0TiCfeG7SV</password>
</server>