o Fixed inconsistent behavior of version getters

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@816133 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-09-17 10:46:52 +00:00
parent 5d459b0c0e
commit eeeee17821
2 changed files with 12 additions and 5 deletions

View File

@ -357,14 +357,11 @@ public class DefaultArtifact
public String getBaseVersion()
{
if ( baseVersion == null )
if ( baseVersion == null && version != null )
{
if ( version == null )
{
throw new NullPointerException( "version was null for " + groupId + ":" + artifactId );
}
setBaseVersionInternal( version );
}
return baseVersion;
}

View File

@ -127,4 +127,14 @@ public class DefaultArtifactTest
assertTrue( artifact.compareTo( artifact1 ) == 0 );
assertTrue( artifact1.compareTo( artifact ) == 0 );
}
public void testNonResolvedVersionRangeConsistentlyYieldsNullVersions()
throws Exception
{
VersionRange vr = VersionRange.createFromVersionSpec( "[1.0,2.0)" );
artifact = new DefaultArtifact( groupId, artifactId, vr, scope, type, null, artifactHandler );
assertEquals( null, artifact.getVersion() );
assertEquals( null, artifact.getBaseVersion() );
}
}