You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by dk...@apache.org on 2007/02/27 18:30:30 UTC

svn commit: r512331 - in /maven/plugins/trunk/maven-gpg-plugin: pom.xml src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java

Author: dkulp
Date: Tue Feb 27 09:30:28 2007
New Revision: 512331

URL: http://svn.apache.org/viewvc?view=rev&rev=512331
Log:
MGPG-1, MGPG-2 - remove requirement of password being passed


Modified:
    maven/plugins/trunk/maven-gpg-plugin/pom.xml
    maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java

Modified: maven/plugins/trunk/maven-gpg-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/pom.xml?view=diff&rev=512331&r1=512330&r2=512331
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-gpg-plugin/pom.xml Tue Feb 27 09:30:28 2007
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>maven-plugins</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
-    <version>8-SNAPSHOT</version>
+    <version>8</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>maven-gpg-plugin</artifactId>

Modified: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java?view=diff&rev=512331&r1=512330&r2=512331
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java (original)
+++ maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java Tue Feb 27 09:30:28 2007
@@ -61,11 +61,28 @@
      * The passphrase to use when signing.
      *
      * @parameter expression="${passphrase}"
-     * @required
      */
     private String passphrase;
 
     /**
+     * The "name" of the key to sign with.  Passed to gpg as --local-user.
+     * 
+     * @parameter expression="${keyname}"
+     */
+    private String keyname;
+
+
+    /**
+     * Passes --use-agent or --no-use-agent to gpg.   If using an agent,
+     * the password is optional as the agent will provide it.
+     * 
+     * @parameter expression="${useAgent}" default-value="false"
+     * @required
+     */
+    private boolean useAgent;
+
+
+    /**
      * The maven project.
      *
      * @parameter expression="${project}"
@@ -96,6 +113,7 @@
     public void execute()
         throws MojoExecutionException
     {
+
         // ----------------------------------------------------------------------------
         // What we need to generateSignatureForArtifact here
         // ----------------------------------------------------------------------------
@@ -194,9 +212,32 @@
 
         cmd.setExecutable( "gpg" + ( SystemUtils.IS_OS_WINDOWS ? ".exe" : "" ) );
 
-        cmd.createArgument().setValue( "--passphrase-fd" );
+        if ( useAgent )
+        {
+            cmd.createArgument().setValue( "--use-agent" );
+        }
+        else
+        {
+            cmd.createArgument().setValue( "--no-use-agent" );
+        }
+
+        InputStream in = null;
+        if ( null != passphrase) 
+        {
+            cmd.createArgument().setValue( "--passphrase-fd" );
+
+            cmd.createArgument().setValue( "0" );
 
-        cmd.createArgument().setValue( "0" );
+            // Prepare the input stream which will be used to pass the passphrase to the executable
+            in = new ByteArrayInputStream( passphrase.getBytes() );
+        }
+
+        if ( null != keyname)
+        {
+            cmd.createArgument().setValue( "--local-user" );
+
+            cmd.createArgument().setValue( keyname );
+        }
 
         cmd.createArgument().setValue( "--armor" );
 
@@ -204,8 +245,6 @@
 
         cmd.createArgument().setFile( file );
 
-        // Prepare the input stream which will be used to pass the passphrase to the executable
-        InputStream in = new ByteArrayInputStream( passphrase.getBytes() );
 
         try
         {