[MNG-6074] Maven should produce an error if no model version has been set in a 
POM file used to build an effective model.


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/744b98e8
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/744b98e8
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/744b98e8

Branch: refs/heads/MNG-6056-feature-toggle
Commit: 744b98e8cf9f2fbe4f73b07927a2c697e8cc6fc2
Parents: 3681fd8
Author: Christian Schulte <[email protected]>
Authored: Sun Jul 31 18:49:17 2016 +0200
Committer: Christian Schulte <[email protected]>
Committed: Sun Jul 31 18:49:17 2016 +0200

----------------------------------------------------------------------
 .../maven/model/validation/DefaultModelValidator.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/744b98e8/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
----------------------------------------------------------------------
diff --git 
a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
 
b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index cdd6c37..5f4f577 100644
--- 
a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ 
b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -100,9 +100,15 @@ public class DefaultModelValidator
         if ( request.getValidationLevel() >= 
ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
         {
             Severity errOn30 = getSeverity( request, 
ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
-            Severity errOn31 = getSeverity( request, 
ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );
 
-            validateStringNotEmpty( "modelVersion", problems, errOn31, 
Version.V20, m.getModelVersion(), m );
+            // [MNG-6074] Maven should produce an error if no model version 
has been set in a POM file used to build an
+            //            effective model.
+            //
+            // As of 3.4, the model version is mandatory even in raw models. 
The XML element still is optional in the
+            // XML schema and this will not change anytime soon. We do not 
want to build effective models based on
+            // models without a version starting with 3.4.
+            validateStringNotEmpty( "modelVersion", problems, Severity.ERROR, 
Version.V20, m.getModelVersion(), m );
+
             validateEnum( "modelVersion", problems, Severity.ERROR, 
Version.V20, m.getModelVersion(), null, m,
                           "4.0.0" );
 

Reply via email to