[MNG-5157] NPE stemming from DefaultModelBuilder.containsCoordinates

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1158623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2011-08-17 11:02:03 +00:00
parent decce3a120
commit e49d091bc4
2 changed files with 16 additions and 2 deletions

View File

@ -909,6 +909,13 @@ public class DefaultModelBuilder
String artifactId = dependency.getArtifactId();
String version = dependency.getVersion();
if ( version == null || version.length() <= 0 )
{
problems.add( Severity.ERROR, "'dependencyManagement.dependencies.dependency.version' for "
+ dependency.getManagementKey() + " is missing.", dependency.getLocation( "" ), null );
continue;
}
String imported = groupId + ':' + artifactId + ':' + version;
if ( importIds.contains( imported ) )
@ -1045,8 +1052,9 @@ public class DefaultModelBuilder
private boolean containsCoordinates( String message, String groupId, String artifactId, String version )
{
return message != null && message.contains( groupId ) && message.contains( artifactId )
&& message.contains( version );
return message != null && ( groupId == null || message.contains( groupId ) )
&& ( artifactId == null || message.contains( artifactId ) )
&& ( version == null || message.contains( version ) );
}
}

View File

@ -356,6 +356,12 @@ public class DefaultModelValidator
{
String key = dependency.getManagementKey();
validateStringNotEmpty( prefix + ".groupId", problems, Severity.ERROR, dependency.getGroupId(), key,
dependency );
validateStringNotEmpty( prefix + ".artifactId", problems, Severity.ERROR, dependency.getArtifactId(), key,
dependency );
if ( "import".equals( dependency.getScope() ) )
{
if ( !"pom".equals( dependency.getType() ) )