mirror of https://github.com/apache/maven.git
MNG-5727 fixed cryptic exception when managed depenency has no <version>
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
5c84bd33ba
commit
ce6f0bfdb5
|
@ -107,6 +107,11 @@ public class MavenRepositorySystem
|
|||
// DefaultProjectBuilder
|
||||
public Artifact createDependencyArtifact( Dependency d )
|
||||
{
|
||||
if ( d.getVersion() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
VersionRange versionRange;
|
||||
try
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue