maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r930720 - in /maven/maven-3/trunk/maven-model-builder/src: main/java/org/apache/maven/model/building/ main/java/org/apache/maven/model/validation/ test/java/org/apache/maven/model/validation/
Date Sun, 04 Apr 2010 17:25:00 GMT
Author: bentmann
Date: Sun Apr  4 17:25:00 2010
New Revision: 930720

URL: http://svn.apache.org/viewvc?rev=930720&view=rev
Log:
o Improved model validation to ignore super POM for plugin version check

Modified:
    maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
    maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
    maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java

Modified: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java?rev=930720&r1=930719&r2=930720&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
(original)
+++ maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
Sun Apr  4 17:25:00 2010
@@ -30,10 +30,13 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Properties;
 
+import org.apache.maven.model.Build;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Parent;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginManagement;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.Repository;
 import org.apache.maven.model.building.ModelProblem.Severity;
@@ -219,6 +222,9 @@ public class DefaultModelBuilder
             }
         }
 
+        problems.setSource( inputModel );
+        checkPluginVersions( lineage, request, problems );
+        
         assembleInheritance( lineage, request, problems );
 
         Model resultModel = resultData.getModel();
@@ -444,6 +450,55 @@ public class DefaultModelBuilder
         }
     }
 
+    private void checkPluginVersions( List<ModelData> lineage, ModelBuildingRequest
request,
+                                      ModelProblemCollector problems )
+    {
+        if ( request.getValidationLevel() < ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
)
+        {
+            return;
+        }
+
+        Map<String, String> versions = new HashMap<String, String>();
+        Map<String, String> managedVersions = new HashMap<String, String>();
+
+        for ( int i = 0, n = lineage.size() - 1; i < n; i++ )
+        {
+            Model model = lineage.get( i ).getModel();
+            Build build = model.getBuild();
+            if ( build != null )
+            {
+                for ( Plugin plugin : build.getPlugins() )
+                {
+                    String key = plugin.getKey();
+                    if ( versions.get( key ) == null )
+                    {
+                        versions.put( key, plugin.getVersion() );
+                    }
+                }
+                PluginManagement mngt = build.getPluginManagement();
+                if ( mngt != null )
+                {
+                    for ( Plugin plugin : mngt.getPlugins() )
+                    {
+                        String key = plugin.getKey();
+                        if ( managedVersions.get( key ) == null )
+                        {
+                            managedVersions.put( key, plugin.getVersion() );
+                        }
+                    }
+                }
+            }
+        }
+
+        for ( String key : versions.keySet() )
+        {
+            if ( versions.get( key ) == null && managedVersions.get( key ) == null
)
+            {
+                problems.add( Severity.WARNING, "'build.plugins.plugin.version' for " + key
+ " is missing.", null );
+            }
+        }
+    }
+
     private void assembleInheritance( List<ModelData> lineage, ModelBuildingRequest
request,
                                       ModelProblemCollector problems )
     {

Modified: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java?rev=930720&r1=930719&r2=930720&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
(original)
+++ maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
Sun Apr  4 17:25:00 2010
@@ -671,11 +671,11 @@ public class DefaultModelValidator
                                            String sourceHint, ModelBuildingRequest request
)
     {
         Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0
);
-        Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1
);
 
-        if ( !validateNotNull( fieldName, problems, errOn31, string, sourceHint ) )
+        if ( string == null )
         {
-            return false;
+            // NOTE: The check for missing plugin versions is handled directly by the model
builder
+            return true;
         }
 
         if ( string.length() > 0 && !hasExpression( string ) && !"RELEASE".equals(
string )

Modified: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java?rev=930720&r1=930719&r2=930720&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
(original)
+++ maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
Sun Apr  4 17:25:00 2010
@@ -273,22 +273,6 @@ public class DefaultModelValidatorTest
         assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getErrors().get(
0 ) );
     }
 
-    public void testMissingPluginVersion()
-        throws Exception
-    {
-        SimpleProblemCollector result =
-            validateEffective( "missing-plugin-version-pom.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1
);
-
-        assertViolations( result, 0, 1, 0 );
-
-        assertEquals( "'build.plugins.plugin.version' for org.apache.maven.plugins:maven-it-plugin
is missing.",
-                      result.getErrors().get( 0 ) );
-
-        result = validateEffective( "missing-plugin-version-pom.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0
);
-
-        assertViolations( result, 0, 0, 1 );
-    }
-
     public void testEmptyPluginVersion()
         throws Exception
     {



Mime
View raw message