Author: bentmann
Date: Wed Aug 13 07:38:33 2008
New Revision: 685574

URL: http://svn.apache.org/viewvc?rev=685574&view=rev
Log:
[MINVOKER-51] NPE when packaging is pom
Submitted by: Peter Janes
Reviewed by: Benjamin Bentmann

o Applied with minor modifications/additions

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml   (with 
props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh   
(with props)
Modified:
    
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml?rev=685574&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml Wed Aug 
13 07:38:33 2008
@@ -0,0 +1,57 @@
+<?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/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>test</groupId>
+  <artifactId>pom-packaging</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Test to check for MINVOKER-51, i.e. NPE when packaging is pom.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>install</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh?rev=685574&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh 
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh Wed 
Aug 13 07:38:33 2008
@@ -0,0 +1,35 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    File itRepoDir = new File( basedir, "target/it-repo" );
+    System.out.println( "Checking for existence of: " + itRepoDir );
+    if ( !itRepoDir.isDirectory() )
+    {
+        System.out.println( "FAILED!" );
+        return false;
+    }
+
+    String[] files = {
+            "test/pom-packaging/1.0-SNAPSHOT/pom-packaging-1.0-SNAPSHOT.pom",
+      };
+    for ( String file : files )
+    {
+        File stagedFile = new File( itRepoDir, file );
+        System.out.println( "Checking for existence of: " + stagedFile );
+        if ( !stagedFile.isFile() )
+        {
+            System.out.println( "FAILED!" );
+            return false;
+        }
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-invoker-plugin/src/it/staging-pom/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java?rev=685574&r1=685573&r2=685574&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
 Wed Aug 13 07:38:33 2008
@@ -176,7 +176,11 @@
             installProjectPom( mvnProject, testRepository );
 
             // Install the main project artifact
-            installer.install( mvnProject.getArtifact().getFile(), 
mvnProject.getArtifact(), testRepository );
+            File artifactFile = mvnProject.getArtifact().getFile();
+            if ( artifactFile != null )
+            {
+                installer.install( artifactFile, mvnProject.getArtifact(), 
testRepository );
+            }
 
             // Install any attached project artifacts
             Collection attachedArtifacts = mvnProject.getAttachedArtifacts();


Reply via email to