You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Eric Blood <wi...@gmail.com> on 2005/05/25 03:07:39 UTC

[m2] parent pom without version causes an NPE

I came across a NPE when a parent pom didn't have a version tag
specified.  I created a test that would recreate the problem, but it
is kind of unwieldy.  Below is the patch to fix it, and if you want I
can submit the test too...

-- 
eblood

Index: maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
===================================================================
--- maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java	(revision
178198)
+++ maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java	(working
copy)
@@ -55,9 +55,10 @@
         // currentVersion
         if ( child.getVersion() == null )
         {
-            // The parent version may have resolved to something
different, so we take what we asked for...
-            // instead of - child.setVersion( parent.getVersion() );
+	  if (child.getParent() != null)
             child.setVersion( child.getParent().getVersion() );
+	  else 
+	    parent.getVersion();
         }
 
         // inceptionYear

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org