You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/02/11 14:47:13 UTC

svn commit: r908968 - in /maven/plugins/trunk/maven-gpg-plugin: ./ src/it/sign-and-deploy-file-with-pom/ src/it/sign-and-deploy-file-without-pom/ src/it/sign-release/ src/main/java/org/apache/maven/plugin/gpg/

Author: bentmann
Date: Thu Feb 11 13:46:56 2010
New Revision: 908968

URL: http://svn.apache.org/viewvc?rev=908968&view=rev
Log:
[MGPG-12] sign-and-deploy does not sign pom.xml

Added:
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.jar   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.pom
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.jar   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java   (with props)
Modified:
    maven/plugins/trunk/maven-gpg-plugin/pom.xml
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/pom.xml
    maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/verify.bsh
    maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java
    maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSigner.java
    maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java

Modified: maven/plugins/trunk/maven-gpg-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/pom.xml?rev=908968&r1=908967&r2=908968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-gpg-plugin/pom.xml Thu Feb 11 13:46:56 2010
@@ -59,6 +59,12 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
       <version>2.0.6</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -75,18 +81,6 @@
       <artifactId>plexus-utils</artifactId>
       <version>2.0.1</version>
     </dependency>
-
-    <dependency>
-      <groupId>org.apache.maven.plugins</groupId>
-      <artifactId>maven-deploy-plugin</artifactId>
-      <version>2.3</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.apache.maven</groupId>
-          <artifactId>maven-core</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
   </dependencies>
 
   <profiles>
@@ -103,6 +97,7 @@
               <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
               <pomIncludes>
                 <pomInclude>*/pom.xml</pomInclude>
+                <pomInclude>sign-and-deploy*</pomInclude>
               </pomIncludes>
               <preBuildHookScript>setup</preBuildHookScript>
               <postBuildHookScript>verify</postBuildHookScript>
@@ -112,9 +107,9 @@
                 <goal>clean</goal>
                 <goal>install</goal>
               </goals>
-              <filterProperties>
-                <gpgHomeDir>${project.build.testOutputDirectory}/gnupg</gpgHomeDir>
-              </filterProperties>
+              <properties>
+                <gpg.homedir>${project.build.testOutputDirectory}/gnupg</gpg.homedir>
+              </properties>
             </configuration>
             <executions>
               <execution>

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties Thu Feb 11 13:46:56 2010
@@ -0,0 +1 @@
+invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:sign-and-deploy-file

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh Thu Feb 11 13:46:56 2010
@@ -0,0 +1,4 @@
+import java.io.*;
+import org.codehaus.plexus.util.*;
+
+FileUtils.deleteDirectory( new File( basedir, "target" ) );

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.jar
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.jar?rev=908968&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.pom?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.pom (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.pom Thu Feb 11 13:46:56 2010
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.gpg.sadfwp</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MGPG-12</name>
+  <description>
+    Tests the signing and deployment of a simple release JAR along with its POM.
+  </description>
+</project>

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties Thu Feb 11 13:46:56 2010
@@ -0,0 +1,4 @@
+file = test.jar
+pomFile = test.pom
+url = file:target/repo
+gpg.passphrase = TEST

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh Thu Feb 11 13:46:56 2010
@@ -0,0 +1,22 @@
+import java.io.*;
+
+File artifactDir = new File( basedir, "target/repo/org/apache/maven/its/gpg/sadfwp/test/1.0" );
+
+String[] expectedFiles = {
+    "test-1.0.jar",
+    "test-1.0.jar.asc",
+    "test-1.0.pom",
+    "test-1.0.pom.asc",
+};
+
+for ( String expectedFile : expectedFiles )
+{
+    File file = new File( artifactDir, expectedFile );
+
+    System.out.println( "Checking for existence of " + file );
+
+    if ( !file.isFile() )
+    {
+        throw new Exception( "Missing file " + file );
+    }
+}

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-pom/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties Thu Feb 11 13:46:56 2010
@@ -0,0 +1 @@
+invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:sign-and-deploy-file

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh Thu Feb 11 13:46:56 2010
@@ -0,0 +1,4 @@
+import java.io.*;
+import org.codehaus.plexus.util.*;
+
+FileUtils.deleteDirectory( new File( basedir, "target" ) );

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.jar
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.jar?rev=908968&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties Thu Feb 11 13:46:56 2010
@@ -0,0 +1,7 @@
+file = test.jar
+groupId = org.apache.maven.its.gpg.sadfwop
+artifactId = test
+version = 1.0
+packaging = jar
+url = file:target/repo
+gpg.passphrase = TEST

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh Thu Feb 11 13:46:56 2010
@@ -0,0 +1,22 @@
+import java.io.*;
+
+File artifactDir = new File( basedir, "target/repo/org/apache/maven/its/gpg/sadfwop/test/1.0" );
+
+String[] expectedFiles = {
+    "test-1.0.jar",
+    "test-1.0.jar.asc",
+    "test-1.0.pom",
+    "test-1.0.pom.asc",
+};
+
+for ( String expectedFile : expectedFiles )
+{
+    File file = new File( artifactDir, expectedFile );
+
+    System.out.println( "Checking for existence of " + file );
+
+    if ( !file.isFile() )
+    {
+        throw new Exception( "Missing file " + file );
+    }
+}

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-without-pom/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/pom.xml?rev=908968&r1=908967&r2=908968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/pom.xml (original)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/pom.xml Thu Feb 11 13:46:56 2010
@@ -47,7 +47,6 @@
         <artifactId>maven-gpg-plugin</artifactId>
         <version>@project.version@</version>
         <configuration>
-          <homedir>@gpgHomeDir@</homedir>
           <passphrase>TEST</passphrase>
         </configuration>
         <executions>

Modified: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/verify.bsh?rev=908968&r1=908967&r2=908968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/verify.bsh (original)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-release/verify.bsh Thu Feb 11 13:46:56 2010
@@ -21,5 +21,3 @@
         throw new Exception( "Missing file " + file );
     }
 }
-
-return true;

Added: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java?rev=908968&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java Thu Feb 11 13:46:56 2010
@@ -0,0 +1,104 @@
+package org.apache.maven.plugin.gpg;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public abstract class AbstractGpgMojo
+    extends AbstractMojo
+{
+
+    /**
+     * The directory from which gpg will load keyrings. If not specified, gpg will use the value configured for its
+     * installation, e.g. <code>~/.gnupg</code> or <code>%APPDATA%/gnupg</code>.
+     * 
+     * @parameter expression="${gpg.homedir}"
+     * @since 1.0
+     */
+    private File homedir;
+
+    /**
+     * The passphrase to use when signing.
+     * 
+     * @parameter expression="${gpg.passphrase}"
+     */
+    private String passphrase;
+
+    /**
+     * The "name" of the key to sign with. Passed to gpg as <code>--local-user</code>.
+     * 
+     * @parameter expression="${gpg.keyname}"
+     */
+    private String keyname;
+
+    /**
+     * Passes <code>--use-agent</code> or <code>--no-use-agent</code> to gpg. If using an agent, the passphrase is
+     * optional as the agent will provide it.
+     * 
+     * @parameter expression="${gpg.useagent}" default-value="false"
+     */
+    private boolean useAgent;
+
+    /**
+     * @parameter default-value="${settings.interactiveMode}"
+     * @readonly
+     */
+    private boolean interactive;
+
+    GpgSigner newSigner( MavenProject project )
+        throws MojoExecutionException, MojoFailureException
+    {
+        GpgSigner signer = new GpgSigner();
+
+        signer.setInteractive( interactive );
+        signer.setKeyName( keyname );
+        signer.setUseAgent( useAgent );
+        signer.setHomeDirectory( homedir );
+
+        signer.setPassPhrase( passphrase );
+        if ( null == passphrase && !useAgent )
+        {
+            if ( !interactive )
+            {
+                throw new MojoFailureException( "Cannot obtain passphrase in batch mode" );
+            }
+            try
+            {
+                signer.setPassPhrase( signer.getPassphrase( project ) );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Exception reading passphrase", e );
+            }
+        }
+
+        return signer;
+    }
+
+}

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/AbstractGpgMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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?rev=908968&r1=908967&r2=908968&view=diff
==============================================================================
--- 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 Thu Feb 11 13:46:56 2010
@@ -31,8 +31,8 @@
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.codehaus.plexus.util.FileUtils;
@@ -48,48 +48,15 @@
  * @phase verify
  */
 public class GpgSignAttachedMojo
-    extends AbstractMojo
+    extends AbstractGpgMojo
 {
 
     private static final String DEFAULT_EXCLUDES[] = new String[] { "**/*.md5", "**/*.sha1", "**/*.asc" };
 
     /**
-     * The directory from which gpg will load keyrings. If not specified, gpg will use the value configured for its
-     * installation, e.g. <code>~/.gnupg</code> or <code>%APPDATA%/gnupg</code>.
-     * 
-     * @parameter expression="${gpg.homedir}"
-     * @since 1.0
-     */
-    private File homedir;
-
-    /**
-     * The passphrase to use when signing.
-     * 
-     * @parameter expression="${gpg.passphrase}"
-     */
-    private String passphrase;
-
-    /**
-     * The "name" of the key to sign with. Passed to gpg as --local-user.
-     * 
-     * @parameter expression="${gpg.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="${gpg.useagent}" default-value="false"
-     * @required
-     */
-    private boolean useAgent;
-
-    /**
      * Skip doing the gpg signing.
      * 
      * @parameter expression="${gpg.skip}" default-value="false"
-     * @required
      */
     private boolean skip;
 
@@ -137,19 +104,9 @@
      */
     private ArtifactHandlerManager artifactHandlerManager;
 
-    /**
-     * @parameter default-value="${settings.interactiveMode}"
-     * @readonly
-     */
-    private boolean interactive;
-
-    private GpgSigner signer = new GpgSigner();
-
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
-
-        String pass = passphrase;
         if ( skip )
         {
             // We're skipping the signing stuff
@@ -173,33 +130,15 @@
         }
         excludes = newExcludes;
 
-        if ( !useAgent && null == pass )
-        {
-            if ( !interactive )
-            {
-                throw new MojoExecutionException( "Cannot obtain passphrase in batch mode" );
-            }
-            try
-            {
-                pass = signer.getPassphrase( project );
-            }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "Exception reading password", e );
-            }
-        }
+        GpgSigner signer = newSigner( project );
 
         // ----------------------------------------------------------------------------
         // What we need to generateSignatureForArtifact here
         // ----------------------------------------------------------------------------
 
-        signer.setInteractive( interactive );
-        signer.setKeyName( keyname );
-        signer.setUseAgent( useAgent );
         signer.setOutputDirectory( outputDirectory );
         signer.setBuildDirectory( new File( project.getBuild().getDirectory() ) );
         signer.setBaseDirectory( project.getBasedir() );
-        signer.setHomeDirectory( homedir );
 
         List signingBundles = new ArrayList();
 
@@ -211,7 +150,7 @@
 
             File projectArtifact = project.getArtifact().getFile();
 
-            File projectArtifactSignature = signer.generateSignatureForArtifact( projectArtifact, pass );
+            File projectArtifactSignature = signer.generateSignatureForArtifact( projectArtifact );
 
             if ( projectArtifactSignature != null )
             {
@@ -234,7 +173,7 @@
             throw new MojoExecutionException( "Error copying POM for signing.", e );
         }
 
-        File pomSignature = signer.generateSignatureForArtifact( pomToSign, pass );
+        File pomSignature = signer.generateSignatureForArtifact( pomToSign );
 
         if ( pomSignature != null )
         {
@@ -251,7 +190,7 @@
 
             File file = artifact.getFile();
 
-            File signature = signer.generateSignatureForArtifact( file, pass );
+            File signature = signer.generateSignatureForArtifact( file );
 
             if ( signature != null )
             {

Modified: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSigner.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSigner.java?rev=908968&r1=908967&r2=908968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSigner.java (original)
+++ maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSigner.java Thu Feb 11 13:46:56 2010
@@ -45,6 +45,8 @@
 
     private String keyname;
 
+    private String passphrase;
+
     private File outputDir;
 
     private File buildDir;
@@ -68,6 +70,11 @@
         keyname = s;
     }
 
+    public void setPassPhrase( String s )
+    {
+        passphrase = s;
+    }
+
     public void setOutputDirectory( File out )
     {
         outputDir = out;
@@ -88,7 +95,7 @@
         homeDir = homeDirectory;
     }
 
-    public File generateSignatureForArtifact( File file, String pass )
+    public File generateSignatureForArtifact( File file )
         throws MojoExecutionException
     {
         File signature = new File( file + SIGNATURE_EXTENSION );
@@ -151,14 +158,14 @@
         }
 
         InputStream in = null;
-        if ( null != pass )
+        if ( null != passphrase )
         {
             cmd.createArg().setValue( "--passphrase-fd" );
 
             cmd.createArg().setValue( "0" );
 
             // Prepare the input stream which will be used to pass the passphrase to the executable
-            in = new ByteArrayInputStream( pass.getBytes() );
+            in = new ByteArrayInputStream( passphrase.getBytes() );
         }
 
         if ( null != keyname )

Modified: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java?rev=908968&r1=908967&r2=908968&view=diff
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java (original)
+++ maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java Thu Feb 11 13:46:56 2010
@@ -20,23 +20,34 @@
  */
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.HashMap;
+import java.io.Reader;
+import java.io.Writer;
 import java.util.Map;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.deployer.ArtifactDeployer;
 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.deploy.DeployFileMojo;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.apache.maven.project.validation.ModelValidationResult;
+import org.apache.maven.project.validation.ModelValidator;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.WriterFactory;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 /**
  * Signs artifacts and installs the artifact in the remote repository.
@@ -47,42 +58,10 @@
  * @since 1.0-beta-4
  */
 public class SignAndDeployFileMojo
-    extends DeployFileMojo
+    extends AbstractGpgMojo
 {
 
     /**
-     * The directory from which gpg will load keyrings. If not specified, gpg will use the value configured for its
-     * installation, e.g. <code>~/.gnupg</code> or <code>%APPDATA%/gnupg</code>.
-     * 
-     * @parameter expression="${gpg.homedir}"
-     * @since 1.0
-     */
-    private File homedir;
-
-    /**
-     * The passphrase to use when signing.
-     * 
-     * @parameter expression="${gpg.passphrase}"
-     */
-    private String passphrase;
-
-    /**
-     * The "name" of the key to sign with. Passed to gpg as --local-user.
-     * 
-     * @parameter expression="${gpg.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="${gpg.useagent}" default-value="false"
-     * @required
-     */
-    private boolean useAgent;
-
-    /**
      * The directory where to store signature files.
      * 
      * @parameter expression="${gpg.asc.directory}"
@@ -90,34 +69,12 @@
     private File ascDirectory;
 
     /**
-     * @parameter default-value="${settings.interactiveMode}"
-     * @readonly
-     */
-    private boolean interactive;
-
-    /**
-     * Maven ArtifactHandlerManager
+     * Flag whether Maven is currently in online/offline mode.
      * 
-     * @component
-     * @required
+     * @parameter default-value="${settings.offline}"
      * @readonly
      */
-    private ArtifactHandlerManager artifactHandlerManager;
-
-    /*
-     * stuff I need to copy since the plugin:plugin doesn't support inheritance outside the current jar
-     */
-    /**
-     * @component
-     */
-    private ArtifactDeployer deployer;
-
-    /**
-     * @parameter default-value="${localRepository}"
-     * @required
-     * @readonly
-     */
-    private ArtifactRepository localRepository;
+    private boolean offline;
 
     /**
      * GroupId of the artifact to be deployed. Retrieved from POM file if specified.
@@ -148,7 +105,14 @@
     private String packaging;
 
     /**
-     * Description passed to a generated POM file (in case of generatePom=true)
+     * Add classifier to the artifact
+     * 
+     * @parameter expression="${classifier}";
+     */
+    private String classifier;
+
+    /**
+     * Description passed to a generated POM file (in case of generatePom=true).
      * 
      * @parameter expression="${generatePom.description}"
      */
@@ -163,32 +127,29 @@
     private File file;
 
     /**
-     * Server Id to map on the &lt;id&gt; under &lt;server&gt; section of settings.xml In most cases, this parameter
-     * will be required for authentication.
+     * Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.
      * 
-     * @parameter expression="${repositoryId}" default-value="remote-repository"
-     * @required
+     * @parameter expression="${pomFile}"
      */
-    private String repositoryId;
+    private File pomFile;
 
     /**
-     * The type of remote repository layout to deploy to. Try <i>legacy</i> for a Maven 1.x-style repository layout.
+     * Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.
      * 
-     * @parameter expression="${repositoryLayout}" default-value="default"
-     * @required
+     * @parameter expression="${generatePom}" default-value="true"
      */
-    private String repositoryLayout;
+    private boolean generatePom;
 
     /**
-     * Map that contains the layouts
+     * Whether to deploy snapshots with a unique version or not.
      * 
-     * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
+     * @parameter expression="${uniqueVersion}" default-value="true"
      */
-    private Map repositoryLayouts;
+    private boolean uniqueVersion;
 
     /**
      * URL where the artifact will be deployed. <br/>
-     * ie ( file://C:\m2-repo or scp://host.com/path/to/repo )
+     * ie ( file:///C:/m2-repo or scp://host.com/path/to/repo )
      * 
      * @parameter expression="${url}"
      * @required
@@ -196,188 +157,300 @@
     private String url;
 
     /**
-     * Component used to create an artifact
+     * Server Id to map on the &lt;id&gt; under &lt;server&gt; section of <code>settings.xml</code>. In most cases, this
+     * parameter will be required for authentication.
      * 
-     * @component
+     * @parameter expression="${repositoryId}" default-value="remote-repository"
+     * @required
      */
-    private ArtifactFactory artifactFactory;
+    private String repositoryId;
 
     /**
-     * Component used to create a repository
+     * The type of remote repository layout to deploy to. Try <i>legacy</i> for a Maven 1.x-style repository layout.
      * 
+     * @parameter expression="${repositoryLayout}" default-value="default"
+     */
+    private String repositoryLayout;
+
+    /**
      * @component
      */
-    private ArtifactRepositoryFactory repositoryFactory;
+    private ArtifactDeployer deployer;
 
     /**
-     * Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.
+     * @parameter default-value="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * Map that contains the layouts.
      * 
-     * @parameter expression="${pomFile}"
+     * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
      */
-    private File pomFile;
+    private Map repositoryLayouts;
 
     /**
-     * Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.
+     * Component used to create an artifact
      * 
-     * @parameter expression="${generatePom}" default-value="true"
+     * @component
      */
-    private boolean generatePom;
+    private ArtifactFactory artifactFactory;
 
     /**
-     * Add classifier to the artifact
+     * Component used to create a repository
      * 
-     * @parameter expression="${classifier}";
+     * @component
      */
-    private String classifier;
+    private ArtifactRepositoryFactory repositoryFactory;
 
     /**
-     * Whether to deploy snapshots with a unique version or not.
+     * The component used to validate the user-supplied artifact coordinates.
      * 
-     * @parameter expression="${uniqueVersion}" default-value="true"
+     * @component
      */
-    private boolean uniqueVersion;
+    private ModelValidator modelValidator;
 
-    private final GpgSigner signer = new GpgSigner();
+    private void initProperties()
+        throws MojoExecutionException
+    {
+        // Process the supplied POM (if there is one)
+        if ( pomFile != null )
+        {
+            generatePom = false;
+
+            Model model = readModel( pomFile );
+
+            processModel( model );
+        }
+    }
 
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {
-        ArtifactHandler handler = new DefaultArtifactHandler( "asc" );
-        Map map = new HashMap();
-        map.put( "asc", handler );
-        artifactHandlerManager.addHandlers( map );
-
-        copyToParent();
-        ArtifactDeployer deployer = getDeployer();
-        signer.setInteractive( interactive );
-        signer.setKeyName( keyname );
-        signer.setUseAgent( useAgent );
+        GpgSigner signer = newSigner( null );
         signer.setOutputDirectory( ascDirectory );
-        signer.setBaseDirectory( new File( "foo" ).getAbsoluteFile().getParentFile().getAbsoluteFile() );
-        signer.setHomeDirectory( homedir );
+        signer.setBaseDirectory( new File( "" ).getAbsoluteFile() );
+
+        if ( offline )
+        {
+            throw new MojoFailureException( "Cannot deploy artifacts when Maven is in offline mode" );
+        }
+
+        initProperties();
+
+        validateArtifactInformation();
+
+        if ( !file.exists() )
+        {
+            throw new MojoFailureException( file.getPath() + " not found." );
+        }
 
-        setDeployer( new SignedArtifactDeployer( deployer, passphrase ) );
-        super.execute();
+        ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( repositoryLayout );
+        if ( layout == null )
+        {
+            throw new MojoFailureException( "Invalid repository layout: " + repositoryLayout );
+        }
+
+        ArtifactRepository deploymentRepository =
+            repositoryFactory.createDeploymentArtifactRepository( repositoryId, url, layout, uniqueVersion );
+
+        if ( StringUtils.isEmpty( deploymentRepository.getProtocol() ) )
+        {
+            throw new MojoFailureException( "No transfer protocol found." );
+        }
+
+        Artifact artifact =
+            artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );
+
+        if ( file.equals( getLocalRepoFile( artifact ) ) )
+        {
+            throw new MojoFailureException( "Cannot deploy artifact from the local repository: " + file );
+        }
+
+        File fileSig = signer.generateSignatureForArtifact( file );
+        ArtifactMetadata metadata = new AscArtifactMetadata( artifact, fileSig, false );
+        artifact.addMetadata( metadata );
+
+        if ( !"pom".equals( packaging ) )
+        {
+            if ( pomFile == null && generatePom )
+            {
+                pomFile = generatePomFile();
+            }
+            if ( pomFile != null )
+            {
+                metadata = new ProjectArtifactMetadata( artifact, pomFile );
+                artifact.addMetadata( metadata );
+
+                fileSig = signer.generateSignatureForArtifact( pomFile );
+                metadata = new AscArtifactMetadata( artifact, fileSig, true );
+                artifact.addMetadata( metadata );
+            }
+        }
+
+        try
+        {
+            deployer.deploy( file, artifact, deploymentRepository, localRepository );
+        }
+        catch ( ArtifactDeploymentException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
     }
 
-    /*
-     * this sucks. The plugin:plugin won't find properties in parent classes unless they exist in the same compilation
-     * unit. Thus, we need to declare our own and copy them to the parent. HOWEVER, the DeployFileMojo doesn't have
-     * public setters. Thus, we need to do crappy field copies.
+    /**
+     * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist
+     * (yet).
+     * 
+     * @param artifact The artifact whose local repo path should be determined, must not be <code>null</code>.
+     * @return The absolute path to the artifact when installed, never <code>null</code>.
      */
-    private void copyToParent()
-        throws MojoExecutionException
+    private File getLocalRepoFile( Artifact artifact )
     {
-        this.setDeployer( deployer );
-        this.setLocalRepository( localRepository );
+        String path = localRepository.pathOf( artifact );
+        return new File(localRepository.getBasedir(), path );
+    }
 
-        setDeployFileMojoField( "groupId", groupId );
-        setDeployFileMojoField( "artifactId", artifactId );
-        setDeployFileMojoField( "version", version );
-        setDeployFileMojoField( "packaging", packaging );
-        setDeployFileMojoField( "description", description );
-        setDeployFileMojoField( "file", file );
-        setDeployFileMojoField( "repositoryId", repositoryId );
-        setDeployFileMojoField( "repositoryLayout", repositoryLayout );
-        setDeployFileMojoField( "repositoryLayouts", repositoryLayouts );
-        setDeployFileMojoField( "url", url );
-        setDeployFileMojoField( "artifactFactory", artifactFactory );
-        setDeployFileMojoField( "repositoryFactory", repositoryFactory );
-        setDeployFileMojoField( "pomFile", pomFile );
-        setDeployFileMojoField( "generatePom", Boolean.valueOf( generatePom ) );
-        setDeployFileMojoField( "classifier", classifier );
-        setDeployFileMojoField( "uniqueVersion", Boolean.valueOf( uniqueVersion ) );
+    /**
+     * Process the supplied pomFile to get groupId, artifactId, version, and packaging
+     *
+     * @param model The POM to extract missing artifact coordinates from, must not be <code>null</code>.
+     */
+    private void processModel( Model model )
+    {
+        Parent parent = model.getParent();
+
+        if ( this.groupId == null )
+        {
+            this.groupId = model.getGroupId();
+            if ( this.groupId == null && parent != null )
+            {
+                this.groupId = parent.getGroupId();
+            }
+        }
+        if ( this.artifactId == null )
+        {
+            this.artifactId = model.getArtifactId();
+        }
+        if ( this.version == null )
+        {
+            this.version = model.getVersion();
+            if ( this.version == null && parent != null )
+            {
+                this.version = parent.getVersion();
+            }
+        }
+        if ( this.packaging == null )
+        {
+            this.packaging = model.getPackaging();
+        }
     }
 
-    private void setDeployFileMojoField( String name, Object value )
+    /**
+     * Extract the model from the specified POM file.
+     * 
+     * @param pomFile The path of the POM file to parse, must not be <code>null</code>.
+     * @return The model from the POM file, never <code>null</code>.
+     * @throws MojoExecutionException If the file doesn't exist of cannot be read.
+     */
+    private Model readModel( File pomFile )
         throws MojoExecutionException
     {
+        Reader reader = null;
         try
         {
-            Field f = DeployFileMojo.class.getDeclaredField( name );
-            f.setAccessible( true );
-            f.set( this, value );
+            reader = ReaderFactory.newXmlReader( pomFile );
+            return new MavenXpp3Reader().read( reader );
+        }
+        catch ( FileNotFoundException e )
+        {
+            throw new MojoExecutionException( "POM not found " + pomFile, e );
         }
-        catch ( Exception e )
+        catch ( IOException e )
         {
-            throw new MojoExecutionException( "Could not set field " + name, e );
+            throw new MojoExecutionException( "Error reading POM " + pomFile, e );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new MojoExecutionException( "Error parsing POM " + pomFile, e );
+        }
+        finally
+        {
+            IOUtil.close( reader );
         }
     }
 
-    public void setDeployer( ArtifactDeployer deployer )
+    /**
+     * Generates a minimal POM from the user-supplied artifact information.
+     * 
+     * @return The path to the generated POM file, never <code>null</code>.
+     * @throws MojoExecutionException If the generation failed.
+     */
+    private File generatePomFile()
+        throws MojoExecutionException
     {
-        this.deployer = deployer;
-        super.setDeployer( deployer );
-    }
+        Model model = generateModel();
 
-    public void setLocalRepository( ArtifactRepository localRepository )
-    {
-        this.localRepository = localRepository;
-        super.setLocalRepository( localRepository );
+        Writer fw = null;
+        try
+        {
+            File tempFile = File.createTempFile( "mvndeploy", ".pom" );
+            tempFile.deleteOnExit();
+
+            fw = WriterFactory.newXmlWriter( tempFile );
+            new MavenXpp3Writer().write( fw, model );
+
+            return tempFile;
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error writing temporary pom file: " + e.getMessage(), e );
+        }
+        finally
+        {
+            IOUtil.close( fw );
+        }
     }
 
-    private class SignedArtifactDeployer
-        implements ArtifactDeployer
+    /**
+     * Generates a minimal model from the user-supplied artifact information.
+     * 
+     * @return The generated model, never <code>null</code>.
+     */
+    private Model generateModel()
     {
-        ArtifactDeployer deployer;
+        Model model = new Model();
 
-        String pass;
+        model.setModelVersion( "4.0.0" );
 
-        public SignedArtifactDeployer( ArtifactDeployer dep, String passphrase )
-            throws MojoExecutionException
-        {
-            deployer = dep;
-            pass = passphrase;
-            if ( !useAgent && null == pass )
-            {
-                if ( !interactive )
-                {
-                    throw new MojoExecutionException( "Cannot obtain passphrase in batch mode" );
-                }
-                try
-                {
-                    pass = signer.getPassphrase( null );
-                }
-                catch ( IOException e )
-                {
-                    throw new MojoExecutionException( "Exception reading password", e );
-                }
-            }
-        }
+        model.setGroupId( groupId );
+        model.setArtifactId( artifactId );
+        model.setVersion( version );
+        model.setPackaging( packaging );
 
-        public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository,
-                            ArtifactRepository localRepository )
-            throws ArtifactDeploymentException
-        {
-            try
-            {
-                File fileSig = signer.generateSignatureForArtifact( source, pass );
-                ArtifactMetadata metadata = new AscArtifactMetadata( artifact, fileSig, false );
-                artifact.addMetadata( metadata );
+        model.setDescription( description );
 
-                if ( !generatePom && pomFile != null )
-                {
-                    fileSig = signer.generateSignatureForArtifact( pomFile, pass );
-                    metadata = new AscArtifactMetadata( artifact, fileSig, true );
-                    artifact.addMetadata( metadata );
-                }
+        return model;
+    }
 
-                deployer.deploy( source, artifact, deploymentRepository, localRepository );
-            }
-            catch ( MojoExecutionException e )
-            {
-                throw new ArtifactDeploymentException( e.getMessage(), e );
-            }
+    /**
+     * Validates the user-supplied artifact information.
+     * 
+     * @throws MojoFailureException If any artifact coordinate is invalid.
+     */
+    private void validateArtifactInformation()
+        throws MojoFailureException
+    {
+        Model model = generateModel();
 
-        }
+        ModelValidationResult result = modelValidator.validate( model );
 
-        public void deploy( String basedir, String finalName, Artifact artifact,
-                            ArtifactRepository deploymentRepository, ArtifactRepository localRepository )
-            throws ArtifactDeploymentException
-        {
-            String extension = artifact.getArtifactHandler().getExtension();
-            File source = new File( basedir, finalName + "." + extension );
-            deploy( source, artifact, deploymentRepository, localRepository );
+        if ( result.getMessageCount() > 0 )
+        {
+            throw new MojoFailureException( "The artifact information is incomplete or not valid:\n"
+                + result.render( "  " ) );
         }
     }