maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r888390 - in /maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model: building/DefaultModelBuilder.java building/FilterModelBuildingRequest.java validation/DefaultModelValidator.java
Date Tue, 08 Dec 2009 13:13:39 GMT
Author: bentmann
Date: Tue Dec  8 13:13:39 2009
New Revision: 888390

URL: http://svn.apache.org/viewvc?rev=888390&view=rev
Log:
[MNG-4488] [regression] Parent POMs resolved from repository are validated in strict mode

Added:
    maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
  (with props)
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

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=888390&r1=888389&r2=888390&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
Tue Dec  8 13:13:39 2009
@@ -589,7 +589,20 @@
             throw new ModelBuildingException( problems.getRootModelId(), problems.getProblems()
);
         }
 
-        Model parentModel = readModel( modelSource, null, request, problems );
+        ModelBuildingRequest lenientRequest = request;
+        if ( request.getValidationLevel() > ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
)
+        {
+            lenientRequest = new FilterModelBuildingRequest( request )
+            {
+                @Override
+                public int getValidationLevel()
+                {
+                    return ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0;
+                }
+            };
+        }
+
+        Model parentModel = readModel( modelSource, null, lenientRequest, problems );
 
         ModelData parentData =
             new ModelData( parentModel, parent.getGroupId(), parent.getArtifactId(), parent.getVersion()
);

Added: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java?rev=888390&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
(added)
+++ maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
Tue Dec  8 13:13:39 2009
@@ -0,0 +1,215 @@
+package org.apache.maven.model.building;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.model.Profile;
+import org.apache.maven.model.resolution.ModelResolver;
+
+/**
+ * A model building request that delegates all methods invocations to another request, meant
for easy transformations by
+ * subclassing.
+ * 
+ * @author Benjamin Bentmann
+ */
+class FilterModelBuildingRequest
+    implements ModelBuildingRequest
+{
+
+    protected ModelBuildingRequest request;
+
+    public FilterModelBuildingRequest( ModelBuildingRequest request )
+    {
+        this.request = request;
+    }
+
+    public File getPomFile()
+    {
+        return request.getPomFile();
+    }
+
+    public FilterModelBuildingRequest setPomFile( File pomFile )
+    {
+        request.setPomFile( pomFile );
+
+        return this;
+    }
+
+    public ModelSource getModelSource()
+    {
+        return request.getModelSource();
+    }
+
+    public FilterModelBuildingRequest setModelSource( ModelSource modelSource )
+    {
+        request.setModelSource( modelSource );
+
+        return this;
+    }
+
+    public int getValidationLevel()
+    {
+        return request.getValidationLevel();
+    }
+
+    public FilterModelBuildingRequest setValidationLevel( int validationLevel )
+    {
+        request.setValidationLevel( validationLevel );
+
+        return this;
+    }
+
+    public boolean isProcessPlugins()
+    {
+        return request.isProcessPlugins();
+    }
+
+    public FilterModelBuildingRequest setProcessPlugins( boolean processPlugins )
+    {
+        request.setProcessPlugins( processPlugins );
+
+        return this;
+    }
+
+    public boolean isTwoPhaseBuilding()
+    {
+        return request.isTwoPhaseBuilding();
+    }
+
+    public FilterModelBuildingRequest setTwoPhaseBuilding( boolean twoPhaseBuilding )
+    {
+        request.setTwoPhaseBuilding( twoPhaseBuilding );
+
+        return this;
+    }
+
+    public List<Profile> getProfiles()
+    {
+        return request.getProfiles();
+    }
+
+    public FilterModelBuildingRequest setProfiles( List<Profile> profiles )
+    {
+        request.setProfiles( profiles );
+
+        return this;
+    }
+
+    public List<String> getActiveProfileIds()
+    {
+        return request.getActiveProfileIds();
+    }
+
+    public FilterModelBuildingRequest setActiveProfileIds( List<String> activeProfileIds
)
+    {
+        request.setActiveProfileIds( activeProfileIds );
+
+        return this;
+    }
+
+    public List<String> getInactiveProfileIds()
+    {
+        return request.getInactiveProfileIds();
+    }
+
+    public FilterModelBuildingRequest setInactiveProfileIds( List<String> inactiveProfileIds
)
+    {
+        request.setInactiveProfileIds( inactiveProfileIds );
+
+        return this;
+    }
+
+    public Properties getSystemProperties()
+    {
+        return request.getSystemProperties();
+    }
+
+    public FilterModelBuildingRequest setSystemProperties( Properties systemProperties )
+    {
+        request.setSystemProperties( systemProperties );
+
+        return this;
+    }
+
+    public Properties getUserProperties()
+    {
+        return request.getUserProperties();
+    }
+
+    public FilterModelBuildingRequest setUserProperties( Properties userProperties )
+    {
+        request.setUserProperties( userProperties );
+
+        return this;
+    }
+
+    public Date getBuildStartTime()
+    {
+        return request.getBuildStartTime();
+    }
+
+    public ModelBuildingRequest setBuildStartTime( Date buildStartTime )
+    {
+        request.setBuildStartTime( buildStartTime );
+
+        return this;
+    }
+
+    public ModelResolver getModelResolver()
+    {
+        return request.getModelResolver();
+    }
+
+    public FilterModelBuildingRequest setModelResolver( ModelResolver modelResolver )
+    {
+        request.setModelResolver( modelResolver );
+
+        return this;
+    }
+
+    public ModelBuildingListener getModelBuildingListener()
+    {
+        return request.getModelBuildingListener();
+    }
+
+    public ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener
)
+    {
+        request.setModelBuildingListener( modelBuildingListener );
+
+        return this;
+    }
+
+    public ModelCache getModelCache()
+    {
+        return request.getModelCache();
+    }
+
+    public FilterModelBuildingRequest setModelCache( ModelCache modelCache )
+    {
+        request.setModelCache( modelCache );
+
+        return this;
+    }
+
+}

Propchange: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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=888390&r1=888389&r2=888390&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
Tue Dec  8 13:13:39 2009
@@ -76,6 +76,8 @@
 
         if ( request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
)
         {
+            Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0
);
+
             validateEnum( "modelVersion", problems, Severity.ERROR, model.getModelVersion(),
null, "4.0.0" );
             validateStringNoExpression( "groupId", problems, Severity.WARNING, model.getGroupId()
);
             validateStringNoExpression( "artifactId", problems, Severity.WARNING, model.getArtifactId()
);
@@ -99,7 +101,7 @@
             {
                 if ( !profileIds.add( profile.getId() ) )
                 {
-                    addViolation( problems, Severity.ERROR, "profiles.profile.id must be
unique"
+                    addViolation( problems, errOn30, "profiles.profile.id must be unique"
                         + " but found duplicate profile with id " + profile.getId() );
                 }
 
@@ -354,6 +356,8 @@
     private void validateDependencies( ModelProblemCollector problems, List<Dependency>
dependencies, String prefix,
                                        ModelBuildingRequest request )
     {
+        Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0
);
+
         Map<String, Dependency> index = new HashMap<String, Dependency>();
 
         for ( Dependency dependency : dependencies )
@@ -363,7 +367,7 @@
             if ( "pom".equals( dependency.getType() ) && "import".equals( dependency.getScope()
)
                 && StringUtils.isNotEmpty( dependency.getClassifier() ) )
             {
-                addViolation( problems, Severity.ERROR, "'" + prefix + ".classifier' must
be empty for imported POM: " + key );
+                addViolation( problems, errOn30, "'" + prefix + ".classifier' must be empty
for imported POM: " + key );
             }
             else if ( "system".equals( dependency.getScope() ) )
             {
@@ -379,8 +383,6 @@
 
             if ( existing != null )
             {
-                Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0
);
-
                 String msg;
                 if ( equals( existing.getVersion(), dependency.getVersion() ) )
                 {



Mime
View raw message