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/05/29 11:48:53 UTC

svn commit: r949366 - in /maven/plugins/trunk/maven-gpg-plugin/src: it/no-main-artifact/ it/no-main-artifact/pom.xml it/no-main-artifact/verify.bsh it/sign-release/verify.bsh main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java

Author: bentmann
Date: Sat May 29 09:48:52 2010
New Revision: 949366

URL: http://svn.apache.org/viewvc?rev=949366&view=rev
Log:
[MGPG-20] Signing fails if project has no main artifact but only attached artifacts with classifiers

Added:
    maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/
    maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml   (with props)
    maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/verify.bsh   (with props)
Modified:
    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

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml?rev=949366&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml Sat May 29 09:48:52 2010
@@ -0,0 +1,90 @@
+<?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.nma</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests the signing of a project that produces no main artifact but only attached artifacts (MGPG-20).
+  </description>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-gpg-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <passphrase>TEST</passphrase>
+        </configuration>
+        <executions>
+          <execution>
+            <id>sign-artifacts</id>
+            <goals>
+              <goal>sign</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <version>2.3</version>
+        <configuration>
+          <updateReleaseInfo>true</updateReleaseInfo>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.1</version>
+        <configuration>
+          <classifier>jdk15</classifier>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.3.1</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/verify.bsh?rev=949366&view=auto
==============================================================================
--- maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/verify.bsh (added)
+++ maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/verify.bsh Sat May 29 09:48:52 2010
@@ -0,0 +1,22 @@
+import java.io.*;
+
+File artifactDir = new File( localRepositoryPath, "org/apache/maven/its/gpg/nma/test/1.0" );
+
+String[] expectedFiles = {
+    "test-1.0.pom",
+    "test-1.0.pom.asc",
+    "test-1.0-jdk15.jar",
+    "test-1.0-jdk15.jar.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/no-main-artifact/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-gpg-plugin/src/it/no-main-artifact/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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=949366&r1=949365&r2=949366&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 Sat May 29 09:48:52 2010
@@ -7,6 +7,7 @@ String[] expectedFiles = {
     "test-1.0.pom.asc",
     "test-1.0.jar",
     "test-1.0.jar.asc",
+    "test-1.0-sources.jar",
     "test-1.0-sources.jar.asc",
 };
 

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=949366&r1=949365&r2=949366&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 Sat May 29 09:48:52 2010
@@ -151,17 +151,25 @@ public class GpgSignAttachedMojo
 
             File projectArtifact = project.getArtifact().getFile();
 
-            if ( projectArtifact == null )
+            if ( projectArtifact != null && projectArtifact.isFile() )
+            {
+                getLog().debug( "Generating signature for " + projectArtifact );
+
+                File projectArtifactSignature = signer.generateSignatureForArtifact( projectArtifact );
+
+                if ( projectArtifactSignature != null )
+                {
+                    signingBundles.add( new SigningBundle( project.getArtifact().getType(), projectArtifactSignature ) );
+                }
+            }
+            else if ( project.getAttachedArtifacts().isEmpty() )
             {
                 throw new MojoFailureException( "The project artifact has not been assembled yet. "
                     + "Please do not invoke this goal before the lifecycle phase \"package\"." );
             }
-
-            File projectArtifactSignature = signer.generateSignatureForArtifact( projectArtifact );
-
-            if ( projectArtifactSignature != null )
+            else
             {
-                signingBundles.add( new SigningBundle( project.getArtifact().getType(), projectArtifactSignature ) );
+                getLog().debug( "Main artifact not assembled, skipping signature generation" );
             }
         }
 
@@ -180,6 +188,8 @@ public class GpgSignAttachedMojo
             throw new MojoExecutionException( "Error copying POM for signing.", e );
         }
 
+        getLog().debug( "Generating signature for " + pomToSign );
+
         File pomSignature = signer.generateSignatureForArtifact( pomToSign );
 
         if ( pomSignature != null )
@@ -197,6 +207,8 @@ public class GpgSignAttachedMojo
 
             File file = artifact.getFile();
 
+            getLog().debug( "Generating signature for " + file );
+
             File signature = signer.generateSignatureForArtifact( file );
 
             if ( signature != null )