MNG-5727 fixed cryptic exception when managed depenency has no <version>

Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
Igor Fedorenko 2014-11-25 15:44:43 -05:00
parent 5c84bd33ba
commit ce6f0bfdb5
4 changed files with 50 additions and 4 deletions

View File

@ -107,6 +107,11 @@ public class MavenRepositorySystem
// DefaultProjectBuilder
public Artifact createDependencyArtifact( Dependency d )
{
if ( d.getVersion() == null )
{
return null;
}
VersionRange versionRange;
try
{

View File

@ -807,14 +807,12 @@ public class DefaultProjectBuilder
{
Artifact artifact = repositorySystem.createDependencyArtifact( d );
if ( artifact == null )
if ( artifact != null )
{
map = Collections.emptyMap();
}
map.put( d.getManagementKey(), artifact );
}
}
}
else
{
map = Collections.emptyMap();

View File

@ -65,4 +65,23 @@ public class ProjectBuilderTest
assertNotNull( result.getProject().getParentFile() );
}
public void testVersionlessManagedDependency()
throws Exception
{
File pomFile = new File( "src/test/resources/projects/versionless-managed-dependency.xml" );
MavenSession mavenSession = createMavenSession( null );
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
configuration.setRepositorySession( mavenSession.getRepositorySession() );
try
{
lookup( org.apache.maven.project.ProjectBuilder.class ).build( pomFile, configuration );
fail();
}
catch ( ProjectBuildingException e )
{
// this is expected
}
}
}

View File

@ -0,0 +1,24 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>versionless-managed-dependency.xml</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>a</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>a</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
</project>