o Fixed validation of model version

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@817609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-09-22 11:43:11 +00:00
parent 6d470389c6
commit 704b29c2d4
5 changed files with 43 additions and 2 deletions

View File

@ -20,7 +20,6 @@
*/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@ -165,6 +164,12 @@ protected void mergeModel_CiManagement( Model target, Model source, boolean sour
}
}
@Override
protected void mergeModel_ModelVersion( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
{
// neither inherited nor injected
}
@Override
protected void mergeModel_Profiles( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
{

View File

@ -73,6 +73,7 @@ public void validateRawModel( Model model, ModelBuildingRequest request, ModelPr
if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
{
validateEnum( "modelVersion", problems, false, model.getModelVersion(), null, "4.0.0" );
validateStringNoExpression( "groupId", problems, true, model.getGroupId() );
validateStringNoExpression( "artifactId", problems, true, model.getArtifactId() );
validateStringNoExpression( "version", problems, true, model.getVersion() );

View File

@ -112,6 +112,17 @@ public void testMissingModelVersion()
assertEquals( "'modelVersion' is missing.", result.getErrors().get( 0 ) );
}
public void testBadModelVersion()
throws Exception
{
SimpleProblemCollector result =
validateRaw( "bad-modelVersion.xml", ModelBuildingRequest.VALIDATION_LEVEL_STRICT );
assertViolations( result, 1, 0 );
assertTrue( result.getErrors().get( 0 ).indexOf( "modelVersion" ) > -1 );
}
public void testMissingArtifactId()
throws Exception
{

View File

@ -0,0 +1,25 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>99.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>0.1</version>
</project>

View File

@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;