mirror of https://github.com/apache/maven.git
o Propagated new validator API up to project builder
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@790344 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2b44c968f0
commit
ed6ff2be82
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
|
@ -128,7 +129,7 @@ public class DefaultMavenProjectBuilder
|
|||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepositories( remoteRepositories );
|
||||
configuration.setProcessPlugins( false );
|
||||
configuration.setLenientValidation( true );
|
||||
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
||||
|
||||
return buildFromRepository( artifact, configuration );
|
||||
}
|
||||
|
|
|
@ -182,8 +182,7 @@ public class DefaultProjectBuilder
|
|||
configuration.getRemoteRepositories() );
|
||||
|
||||
ModelBuildingRequest request = new DefaultModelBuildingRequest();
|
||||
request.setValidationLevel( configuration.istLenientValidation() ? ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL
|
||||
: ModelBuildingRequest.VALIDATION_LEVEL_STRICT );
|
||||
request.setValidationLevel( configuration.getValidationLevel() );
|
||||
request.setProcessPlugins( configuration.isProcessPlugins() );
|
||||
request.setProfiles( configuration.getProfiles() );
|
||||
request.setActiveProfileIds( configuration.getActiveProfileIds() );
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.model.ModelEventListener;
|
||||
|
||||
@Deprecated
|
||||
|
@ -34,6 +35,7 @@ public class DefaultProjectBuilderConfiguration
|
|||
public DefaultProjectBuilderConfiguration()
|
||||
{
|
||||
setProcessPlugins( false );
|
||||
setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 );
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository )
|
||||
|
@ -66,9 +68,9 @@ public class DefaultProjectBuilderConfiguration
|
|||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration setLenientValidation( boolean lenientValidation )
|
||||
public ProjectBuilderConfiguration setValidationLevel( int validationLevel )
|
||||
{
|
||||
super.setLenientValidation( lenientValidation );
|
||||
super.setValidationLevel( validationLevel );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.model.ModelEventListener;
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class DefaultProjectBuildingRequest
|
|||
|
||||
private MavenProject topProject;
|
||||
|
||||
private boolean lenientValidation;
|
||||
private int validationLevel = ModelBuildingRequest.VALIDATION_LEVEL_STRICT;
|
||||
|
||||
private boolean processPlugins;
|
||||
|
||||
|
@ -167,15 +168,15 @@ public class DefaultProjectBuildingRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setLenientValidation( boolean lenientValidation )
|
||||
public ProjectBuildingRequest setValidationLevel( int validationLevel )
|
||||
{
|
||||
this.lenientValidation = lenientValidation;
|
||||
this.validationLevel = validationLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean istLenientValidation()
|
||||
public int getValidationLevel()
|
||||
{
|
||||
return lenientValidation;
|
||||
return validationLevel;
|
||||
}
|
||||
|
||||
public List<String> getActiveProfileIds()
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
public interface ProjectBuildingRequest
|
||||
|
@ -36,20 +37,18 @@ public interface ProjectBuildingRequest
|
|||
/**
|
||||
* 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.
|
||||
* @param validationLevel The level of validation to perform on processed models, e.g.
|
||||
* {@link ModelBuildingRequest#VALIDATION_LEVEL_STRICT}.
|
||||
* @return This configuration, never {@code null}.
|
||||
*/
|
||||
ProjectBuildingRequest setLenientValidation( boolean lenientValidation );
|
||||
ProjectBuildingRequest setValidationLevel( int validationLevel );
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return The level of validation to perform on processed models.
|
||||
*/
|
||||
boolean istLenientValidation();
|
||||
int getValidationLevel();
|
||||
|
||||
// Profiles
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
|
|||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilder;
|
||||
|
@ -114,7 +115,7 @@ public class MavenMetadataSource
|
|||
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
|
||||
configuration.setLocalRepository( localRepository );
|
||||
configuration.setRemoteRepositories( remoteRepositories );
|
||||
configuration.setLenientValidation( true );
|
||||
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
|
||||
// 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...
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.project.harness.PomTestWrapper;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
|
@ -1678,7 +1678,8 @@ public class PomConstructionTest
|
|||
config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) );
|
||||
config.setActiveProfileIds( Arrays.asList( profileIds ) );
|
||||
config.setExecutionProperties( executionProperties );
|
||||
config.setLenientValidation( lenientValidation );
|
||||
config.setValidationLevel( lenientValidation ? ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0
|
||||
: ModelBuildingRequest.VALIDATION_LEVEL_STRICT );
|
||||
|
||||
return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ) );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue