Search code examples
eclipsemavengnupg

gpg no default secret key error using maven


I am trying to publish my maven project in the Central Repository and I need to sign my artifacts. I have downloaded and installed gpg and created my keyring. When I run a "maven clean deploy" in Eclipse, I get the following error:

gpg: no default secret key: No secret key
gpg: signing failed: No secret key

I have searched online and I am not sure what to do. The only reference about gpg in my pom.xml file is

    <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>   

Thanks!


Solution

  • This questions was asked a long time ago and I cannot remember exactly what I did to fix it. I do remember I had a spelling mistake in my settings.xml file. This is what I changed in my file:

    <profile>
      <id>sign</id>
      <activation>
          <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
          <gpg.passphrase>password</gpg.passphrase>
      </properties> 
    </profile>
    

    This now works.