maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r778404 - in /maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project: ./ artifact/ validation/
Date Mon, 25 May 2009 12:22:32 GMT
Author: bentmann
Date: Mon May 25 12:22:32 2009
New Revision: 778404

URL: http://svn.apache.org/viewvc?rev=778404&view=rev
Log:
o Extended model validator to recognize two different validation levels to account for our
different needs during local builds and metadata retrieval

Modified:
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/ModelValidator.java

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=778404&r1=778403&r2=778404&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Mon May 25 12:22:32 2009
@@ -362,7 +362,7 @@
         {
             project = new MavenProject( model, repositorySystem, this, config );
 
-            validateModel( model, projectDescriptor );
+            validateModel( model, projectDescriptor, config.istLenientValidation() );
 
             Artifact projectArtifact = repositorySystem.createArtifact( project.getGroupId(),
project.getArtifactId(), project.getVersion(), null, project.getPackaging() );
             project.setArtifact( projectArtifact );
@@ -496,11 +496,11 @@
         return transformedDomainModel;
     }
 
-    private void validateModel( Model model, File pomFile )
+    private void validateModel( Model model, File pomFile, boolean lenient )
         throws InvalidProjectModelException
     {
         // Must validate before artifact construction to make sure dependencies are good
-        ModelValidationResult validationResult = validator.validate( model );
+        ModelValidationResult validationResult = validator.validate( model, lenient );
 
         String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId()
);
 

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java?rev=778404&r1=778403&r2=778404&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
Mon May 25 12:22:32 2009
@@ -41,7 +41,9 @@
     private MavenProject topProject;
     
     private boolean processPlugins = true;
-    
+
+    private boolean lenientValidation;
+
     private List<String> activeProfileIds;
     
     private List<String> inactiveProfileIds;
@@ -121,6 +123,17 @@
         return this;
     }
 
+    public ProjectBuilderConfiguration setLenientValidation( boolean lenientValidation )
+    {
+        this.lenientValidation = lenientValidation;
+        return this;
+    }
+
+    public boolean istLenientValidation()
+    {
+        return lenientValidation;
+    }
+
     public List<String> getActiveProfileIds()
     {
         if ( activeProfileIds == null )

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java?rev=778404&r1=778403&r2=778404&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
Mon May 25 12:22:32 2009
@@ -29,7 +29,25 @@
     ProjectBuilderConfiguration setProcessPlugins( boolean processPlugins );
     
     boolean isProcessPlugins();
-        
+
+    /**
+     * Controls the level of validation to perform on processed models. By default, models
are validated in strict mode.
+     * 
+     * @param lenientValidation A flag whether validation should be lenient instead of strict.
For building of projects,
+     *            strict validation should be used to ensure proper building. For the mere
retrievel of dependencies
+     *            during artifact resolution, lenient validation should be used to account
for models of poor quality.
+     * @return This configuration, never {@code null}.
+     */
+    ProjectBuilderConfiguration setLenientValidation( boolean lenientValidation );
+
+    /**
+     * Gets the level of validation to perform on processed models.
+     * 
+     * @return {@code true} if lenient validation is enabled and only the dependency information
is to be validated,
+     *         {@code false} if strict validation is enabled and the entire model is validated.
+     */
+    boolean istLenientValidation();
+
     // Profiles
     
     /**

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=778404&r1=778403&r2=778404&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
Mon May 25 12:22:32 2009
@@ -87,6 +87,7 @@
         ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
         configuration.setLocalRepository( localRepository );
         configuration.setRemoteRepositories( remoteRepositories );
+        configuration.setLenientValidation( true );
         // We don't care about processing plugins here, all we're interested in is the dependencies.
         configuration.setProcessPlugins( false );
         // FIXME: We actually need the execution properties here...

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java?rev=778404&r1=778403&r2=778404&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.java
Mon May 25 12:22:32 2009
@@ -49,6 +49,11 @@
 
     public ModelValidationResult validate( Model model )
     {
+        return validate( model, false );
+    }
+
+    public ModelValidationResult validate( Model model, boolean lenient )
+    {
         ModelValidationResult result = new ModelValidationResult();
 
         validateStringNotEmpty( "modelVersion", result, model.getModelVersion() );

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/ModelValidator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/ModelValidator.java?rev=778404&r1=778403&r2=778404&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/ModelValidator.java
(original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/validation/ModelValidator.java
Mon May 25 12:22:32 2009
@@ -22,12 +22,27 @@
 import org.apache.maven.model.Model;
 
 /**
+ * Checks the model for missing or invalid values.
+ * 
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
 public interface ModelValidator
 {
+
     String ROLE = ModelValidator.class.getName();
 
     ModelValidationResult validate( Model model );
+
+    /**
+     * Checks the specified model for missing or invalid values.
+     * 
+     * @param model The model to validate, must not be {@code null}.
+     * @param lenient A flag whether validation should be lenient instead of strict. For
building of projects, strict
+     *            validation should be used to ensure proper building. For the mere retrievel
of dependencies during
+     *            artifact resolution, lenient validation should be used to account for models
of poor quality.
+     * @return The result of the validation, never {@code null}.
+     */
+    ModelValidationResult validate( Model model, boolean lenient );
+
 }



Mime
View raw message