[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 @@ private void importDependencyManagement( Model model, ModelBuildingRequest reque
String artifactId = dependency.getArtifactId(); String artifactId = dependency.getArtifactId();
String version = dependency.getVersion(); 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; String imported = groupId + ':' + artifactId + ':' + version;
if ( importIds.contains( imported ) ) if ( importIds.contains( imported ) )
@ -1045,8 +1052,9 @@ private void fireEvent( Model model, ModelBuildingRequest request, ModelProblemC
private boolean containsCoordinates( String message, String groupId, String artifactId, String version ) private boolean containsCoordinates( String message, String groupId, String artifactId, String version )
{ {
return message != null && message.contains( groupId ) && message.contains( artifactId ) return message != null && ( groupId == null || message.contains( groupId ) )
&& message.contains( version ); && ( artifactId == null || message.contains( artifactId ) )
&& ( version == null || message.contains( version ) );
} }
} }

View File

@ -356,6 +356,12 @@ private void validateRawDependencies( ModelProblemCollector problems, List<Depen
{ {
String key = dependency.getManagementKey(); 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 ( "import".equals( dependency.getScope() ) )
{ {
if ( !"pom".equals( dependency.getType() ) ) if ( !"pom".equals( dependency.getType() ) )