You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2012/10/28 23:30:55 UTC

svn commit: r1403115 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/invocation-emptyproperty/ it/invocation-emptyproperty/src/ it/invocation-emptyproperty/src/it/ it/invocation-emptyproperty/src/it/minvoker-118/ main/java/org/apache/maven/plugi...

Author: rfscholte
Date: Sun Oct 28 22:30:55 2012
New Revision: 1403115

URL: http://svn.apache.org/viewvc?rev=1403115&view=rev
Log:
[MINVOKER-118] Specifying an unset property in <properties> causes a NullPointerException 

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/minvoker-118/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/pom.xml?rev=1403115&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/pom.xml Sun Oct 28 22:30:55 2012
@@ -0,0 +1,66 @@
+<?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>org.apache.maven.plugins.invoker.its</groupId>
+  <artifactId>invocation-emptyporperty</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>Test if the invocation succeeds even if there are empty/unresolved properties</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <debug>true</debug>
+          <goals>
+            <goal>validate</goal>
+          </goals>
+          <properties>
+            <key>value</key>
+            <some.property>${example.property}</some.property>
+            <empty.property/>
+          </properties>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml?rev=1403115&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml Sun Oct 28 22:30:55 2012
@@ -0,0 +1,54 @@
+<?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>org.apache.maven.plugins.invoker.its</groupId>
+  <artifactId>minvoker-118</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>1.1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <AlwaysPass/>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java?rev=1403115&r1=1403114&r2=1403115&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java Sun Oct 28 22:30:55 2012
@@ -19,6 +19,37 @@ package org.apache.maven.plugin.invoker;
  * under the License.
  */
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.io.input.XmlStreamReader;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Profile;
@@ -57,39 +88,8 @@ import org.codehaus.plexus.util.Interpol
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
-import org.apache.commons.io.input.XmlStreamReader;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
 /**
  * Provides common code for mojos invoking sub builds.
  *
@@ -1612,7 +1612,7 @@ public abstract class AbstractInvokerMoj
         throws MojoExecutionException
     {
         Properties collectedTestProperties = new Properties();
-
+        
         if ( testProperties != null )
         {
             collectedTestProperties.putAll( testProperties );
@@ -1620,7 +1620,14 @@ public abstract class AbstractInvokerMoj
 
         if ( properties != null )
         {
-            collectedTestProperties.putAll( properties );
+            // MINVOKER-118: property can have empty value, which is not accepted by collectedTestProperties
+            for ( Map.Entry<String, String> entry : properties.entrySet() )
+            {
+                if ( entry.getValue() != null )
+                {
+                    collectedTestProperties.put( entry.getKey(), entry.getValue() );
+                }
+            }
         }
 
         File propertiesFile = null;