mirror of https://github.com/apache/maven.git
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:
parent
6d470389c6
commit
704b29c2d4
|
@ -20,7 +20,6 @@ package org.apache.maven.model.merge;
|
|||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
|
@ -165,6 +164,12 @@ public class MavenModelMerger
|
|||
}
|
||||
}
|
||||
|
||||
@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 )
|
||||
{
|
||||
|
|
|
@ -73,6 +73,7 @@ public class DefaultModelValidator
|
|||
|
||||
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() );
|
||||
|
|
|
@ -112,6 +112,17 @@ public class DefaultModelValidatorTest
|
|||
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
|
||||
{
|
||||
|
|
|
@ -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>
|
|
@ -21,7 +21,6 @@ package org.apache.maven.model.merge;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
Loading…
Reference in New Issue