3

I am trying to add my school project to the maven repository. I am following this tutorial: https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/. I already generated a key and passphrase successfully and I have added the plugin from that link to my pom file.

When I run command mvn clean deploy -Dgpg.passphrase=mypassphrase it says

[ERROR] Unknown lifecycle phase ".passphrase=...". You must specify a valid lifecycle phase or a goal in
the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 
Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-
resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, 
generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-
package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, 
pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

If I only run mvn clean deploy it says

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign (sign-artifacts) on
project game-engine: Unable to execute gpg command: Error while executing process. 
Cannot run program "gpg.exe": CreateProcess error=2, The system cannot find the file specified -> [Help 1]

I tried to google this, but I was unable to find exactly the same problem. I am running this project on Windows 10.

Crossoni
  • 193
  • 1
  • 10
  • 1
    Based on the first error message you are giving on the command line what you have written...are you starting from plain command line or from inside an IDE? – khmarbaise Dec 11 '19 at 08:49
  • For the second error message: Did you install GnuPG (it's first section in the link you provided)? Test that it works using: gpg --version – jirka.pinkas Dec 11 '19 at 09:43
  • For the first error message: Maybe this is the cause? https://stackoverflow.com/questions/18697461/unknown-lifecycle-phase-maven – jirka.pinkas Dec 11 '19 at 09:46
  • Also did you use cmd or powershell? It's much better to use cmd. – jirka.pinkas Dec 11 '19 at 09:47
  • @khmarbaise Using cmd for the command solved the problem. I was using Visual Studio Code's command line, I did not know that it does not share the same paths as cmd. Thanks for the solution! Is there any way to mark your comment as the answer? I can't find any solution for that from the help menu. – Crossoni Dec 11 '19 at 12:59

2 Answers2

1

Instead of using maven-gpg-plugin for signing you can try another plugin https://www.simplify4u.org/sign-maven-plugin/ which doesn't need external software like gpg for signing.

sign-maven-plugin internally uses the Bouncy Castle library, so the signing process does not depend on the operating system.

It also doesn't depend on conslole which you use, if you can run maven build - signing will work.

Denis Abakumov
  • 355
  • 3
  • 11
Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33
0

you may have change the shell path earlier, the place to change the path is in "settings->Tools->Terminal->Shell path".You can try changing the path to CMD.exe,and then restart your idea.

1

vimuth
  • 5,064
  • 33
  • 79
  • 116