mirror of https://github.com/apache/maven.git
o Made ProjectBuilder use ProjectBuildingRequest for naming consistency within API
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@780115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8c9c57652e
commit
ae675f8157
|
@ -100,7 +100,7 @@ public class DefaultMaven
|
|||
//TODO: We really need to get rid of this requirement in here. If we know there is no project present
|
||||
if ( projects.isEmpty() )
|
||||
{
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( request.getProjectBuildingConfiguration() );
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( request.getProjectBuilderRequest() );
|
||||
projects.put( ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
|
||||
request.setProjectPresent( false );
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class DefaultMaven
|
|||
|
||||
for ( File file : files )
|
||||
{
|
||||
MavenProject project = projectBuilder.build( file, request.getProjectBuildingConfiguration() );
|
||||
MavenProject project = projectBuilder.build( file, request.getProjectBuilderRequest() );
|
||||
|
||||
if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) )
|
||||
{
|
||||
|
|
|
@ -23,8 +23,8 @@ import java.util.Properties;
|
|||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.wagon.events.TransferListener;
|
||||
|
||||
|
@ -232,9 +232,9 @@ public class DefaultMavenExecutionRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
public void setProjectBuildingConfiguration( ProjectBuilderConfiguration projectBuildingConfiguration )
|
||||
public void setProjectBuildingConfiguration( ProjectBuildingRequest projectBuildingConfiguration )
|
||||
{
|
||||
this.projectBuildingConfiguration = projectBuildingConfiguration;
|
||||
this.projectBuilderRequest = projectBuildingConfiguration;
|
||||
}
|
||||
|
||||
public List<String> getActiveProfiles()
|
||||
|
@ -617,7 +617,7 @@ public class DefaultMavenExecutionRequest
|
|||
private Settings settings;
|
||||
|
||||
// calculated from request attributes.
|
||||
private ProjectBuilderConfiguration projectBuildingConfiguration;
|
||||
private ProjectBuildingRequest projectBuilderRequest;
|
||||
|
||||
public MavenExecutionRequest setSettings( Settings settings )
|
||||
{
|
||||
|
@ -706,21 +706,21 @@ public class DefaultMavenExecutionRequest
|
|||
}
|
||||
|
||||
//TODO: this does not belong here.
|
||||
public ProjectBuilderConfiguration getProjectBuildingConfiguration()
|
||||
public ProjectBuildingRequest getProjectBuilderRequest()
|
||||
{
|
||||
if ( projectBuildingConfiguration == null )
|
||||
if ( projectBuilderRequest == null )
|
||||
{
|
||||
projectBuildingConfiguration = new DefaultProjectBuilderConfiguration();
|
||||
projectBuildingConfiguration.setLocalRepository( getLocalRepository() );
|
||||
projectBuildingConfiguration.setExecutionProperties( getProperties() );
|
||||
projectBuildingConfiguration.setRemoteRepositories( getRemoteRepositories() );
|
||||
projectBuildingConfiguration.setActiveProfileIds( getActiveProfiles() );
|
||||
projectBuildingConfiguration.setInactiveProfileIds( getInactiveProfiles() );
|
||||
projectBuildingConfiguration.setProfiles( getProfiles() );
|
||||
projectBuildingConfiguration.setProcessPlugins( true );
|
||||
projectBuilderRequest = new DefaultProjectBuildingRequest();
|
||||
projectBuilderRequest.setLocalRepository( getLocalRepository() );
|
||||
projectBuilderRequest.setExecutionProperties( getProperties() );
|
||||
projectBuilderRequest.setRemoteRepositories( getRemoteRepositories() );
|
||||
projectBuilderRequest.setActiveProfileIds( getActiveProfiles() );
|
||||
projectBuilderRequest.setInactiveProfileIds( getInactiveProfiles() );
|
||||
projectBuilderRequest.setProfiles( getProfiles() );
|
||||
projectBuilderRequest.setProcessPlugins( true );
|
||||
}
|
||||
|
||||
return projectBuildingConfiguration;
|
||||
return projectBuilderRequest;
|
||||
}
|
||||
|
||||
public MavenExecutionRequest addProfile( Profile profile )
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Properties;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.wagon.events.TransferListener;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -202,5 +202,5 @@ public interface MavenExecutionRequest
|
|||
File getUserToolchainsFile();
|
||||
MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
|
||||
|
||||
ProjectBuilderConfiguration getProjectBuildingConfiguration();
|
||||
ProjectBuildingRequest getProjectBuilderRequest();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Properties;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
@ -132,9 +132,9 @@ public class MavenSession
|
|||
return currentProject;
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration getProjectBuilderConfiguration()
|
||||
public ProjectBuildingRequest getProjectBuilderRequest()
|
||||
{
|
||||
return request.getProjectBuildingConfiguration();
|
||||
return request.getProjectBuilderRequest();
|
||||
}
|
||||
|
||||
public List<String> getPluginGroups()
|
||||
|
|
|
@ -19,16 +19,10 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.project.artifact.ProjectArtifact;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @version $Id$
|
||||
|
@ -41,9 +35,6 @@ public class DefaultMavenProjectBuilder
|
|||
@Requirement
|
||||
private ProjectBuilder projectBuilder;
|
||||
|
||||
@Requirement
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// MavenProjectBuilder Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -101,50 +92,7 @@ public class DefaultMavenProjectBuilder
|
|||
public MavenProjectBuildingResult buildProjectWithDependencies( File pomFile, ProjectBuilderConfiguration configuration )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = projectBuilder.build( pomFile, configuration );
|
||||
|
||||
Artifact artifact = new ProjectArtifact( project );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||
.setArtifact( artifact )
|
||||
.setResolveRoot( false )
|
||||
.setResolveTransitively( true )
|
||||
.setLocalRepository( configuration.getLocalRepository() )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
Exception e = result.getExceptions().get( 0 );
|
||||
|
||||
throw new ProjectBuildingException( safeVersionlessKey( project.getGroupId(), project.getArtifactId() ), "Unable to build project due to an invalid dependency version: " + e.getMessage(),
|
||||
pomFile, e );
|
||||
}
|
||||
|
||||
project.setArtifacts( result.getArtifacts() );
|
||||
|
||||
return new MavenProjectBuildingResult( project, result );
|
||||
}
|
||||
|
||||
private static String safeVersionlessKey( String groupId, String artifactId )
|
||||
{
|
||||
String gid = groupId;
|
||||
|
||||
if ( StringUtils.isEmpty( gid ) )
|
||||
{
|
||||
gid = "unknown";
|
||||
}
|
||||
|
||||
String aid = artifactId;
|
||||
|
||||
if ( StringUtils.isEmpty( aid ) )
|
||||
{
|
||||
aid = "unknown";
|
||||
}
|
||||
|
||||
return ArtifactUtils.versionlessKey( gid, aid );
|
||||
return projectBuilder.buildProjectWithDependencies( pomFile, configuration );
|
||||
}
|
||||
|
||||
}
|
|
@ -50,6 +50,7 @@ import org.apache.maven.model.profile.ProfileInjector;
|
|||
import org.apache.maven.model.profile.ProfileSelector;
|
||||
import org.apache.maven.model.validation.ModelValidationResult;
|
||||
import org.apache.maven.model.validation.ModelValidator;
|
||||
import org.apache.maven.project.artifact.ProjectArtifact;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
@ -114,13 +115,13 @@ public class DefaultProjectBuilder
|
|||
// MavenProjectBuilder Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public MavenProject build( File pomFile, ProjectBuilderConfiguration configuration )
|
||||
public MavenProject build( File pomFile, ProjectBuildingRequest configuration )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
return build( pomFile, pomFile.getParentFile(), configuration );
|
||||
}
|
||||
|
||||
private MavenProject build( File pomFile, File projectDirectory, ProjectBuilderConfiguration configuration )
|
||||
private MavenProject build( File pomFile, File projectDirectory, ProjectBuildingRequest configuration )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
String cacheKey = getCacheKey( pomFile, configuration );
|
||||
|
@ -225,7 +226,7 @@ public class DefaultProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
private String getCacheKey( File pomFile, ProjectBuilderConfiguration configuration )
|
||||
private String getCacheKey( File pomFile, ProjectBuildingRequest configuration )
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder( 256 );
|
||||
buffer.append( pomFile.getAbsolutePath() );
|
||||
|
@ -233,7 +234,7 @@ public class DefaultProjectBuilder
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
public MavenProject build( Artifact artifact, ProjectBuilderConfiguration configuration )
|
||||
public MavenProject build( Artifact artifact, ProjectBuildingRequest configuration )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( !artifact.getType().equals( "pom" ) )
|
||||
|
@ -266,7 +267,7 @@ public class DefaultProjectBuilder
|
|||
* I am taking out the profile handling and the interpolation of the base directory until we
|
||||
* spec this out properly.
|
||||
*/
|
||||
public MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
|
||||
public MavenProject buildStandaloneSuperProject( ProjectBuildingRequest config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( superProject != null )
|
||||
|
@ -290,7 +291,37 @@ public class DefaultProjectBuilder
|
|||
return superProject;
|
||||
}
|
||||
|
||||
private Model interpolateModel( Model model, ProjectBuilderConfiguration config, File projectDescriptor )
|
||||
public MavenProjectBuildingResult buildProjectWithDependencies( File pomFile, ProjectBuildingRequest request )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = build( pomFile, request );
|
||||
|
||||
Artifact artifact = new ProjectArtifact( project );
|
||||
|
||||
ArtifactResolutionRequest artifactRequest = new ArtifactResolutionRequest()
|
||||
.setArtifact( artifact )
|
||||
.setResolveRoot( false )
|
||||
.setResolveTransitively( true )
|
||||
.setLocalRepository( request.getLocalRepository() )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( artifactRequest );
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
Exception e = result.getExceptions().get( 0 );
|
||||
|
||||
throw new ProjectBuildingException( safeVersionlessKey( project.getGroupId(), project.getArtifactId() ), "Unable to build project due to an invalid dependency version: " + e.getMessage(),
|
||||
pomFile, e );
|
||||
}
|
||||
|
||||
project.setArtifacts( result.getArtifacts() );
|
||||
|
||||
return new MavenProjectBuildingResult( project, result );
|
||||
}
|
||||
|
||||
private Model interpolateModel( Model model, ProjectBuildingRequest config, File projectDescriptor )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
try
|
||||
|
@ -306,7 +337,7 @@ public class DefaultProjectBuilder
|
|||
return model;
|
||||
}
|
||||
|
||||
private MavenProject fromModelToMavenProject( Model model, File parentFile, ProjectBuilderConfiguration config, File projectDescriptor )
|
||||
private MavenProject fromModelToMavenProject( Model model, File parentFile, ProjectBuildingRequest config, File projectDescriptor )
|
||||
throws InvalidProjectModelException, IOException
|
||||
{
|
||||
MavenProject project;
|
||||
|
@ -329,7 +360,7 @@ public class DefaultProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
private List<Model> build( String projectId, File pomFile, ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
private List<Model> build( String projectId, File pomFile, ProjectBuildingRequest projectBuilderConfiguration )
|
||||
throws ProjectBuildingException, IOException
|
||||
{
|
||||
Model mainModel = readModel( projectId, pomFile, !projectBuilderConfiguration.istLenientValidation() );
|
||||
|
@ -564,7 +595,7 @@ public class DefaultProjectBuilder
|
|||
* @throws ProjectBuildingException
|
||||
*/
|
||||
private List<Model> getDomainModelParentsFromLocalPath( Model model, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, File projectDirectory,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
ProjectBuildingRequest projectBuilderConfiguration )
|
||||
throws IOException, ProjectBuildingException
|
||||
{
|
||||
List<Model> models = new ArrayList<Model>();
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.ModelEventListener;
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
public class DefaultProjectBuildingRequest
|
||||
implements ProjectBuildingRequest
|
||||
{
|
||||
private ArtifactRepository localRepository;
|
||||
|
||||
private List<ArtifactRepository> remoteRepositories;
|
||||
|
||||
private Properties executionProperties;
|
||||
|
||||
private List<ModelEventListener> listeners;
|
||||
|
||||
private MavenProject topProject;
|
||||
|
||||
private boolean processPlugins = true;
|
||||
|
||||
private boolean lenientValidation;
|
||||
|
||||
private List<String> activeProfileIds;
|
||||
|
||||
private List<String> inactiveProfileIds;
|
||||
|
||||
private List<Profile> profiles;
|
||||
|
||||
public MavenProject getTopLevelProjectFromReactor()
|
||||
{
|
||||
return topProject;
|
||||
}
|
||||
|
||||
public void setTopLevelProjectForReactor(MavenProject mavenProject)
|
||||
{
|
||||
this.topProject = mavenProject;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository )
|
||||
{
|
||||
this.localRepository = localRepository;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArtifactRepository getLocalRepository()
|
||||
{
|
||||
return localRepository;
|
||||
}
|
||||
|
||||
public List<ArtifactRepository> getRemoteRepositories()
|
||||
{
|
||||
if ( remoteRepositories == null )
|
||||
{
|
||||
remoteRepositories = new ArrayList<ArtifactRepository>();
|
||||
}
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
|
||||
{
|
||||
this.remoteRepositories = remoteRepositories;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Properties getExecutionProperties()
|
||||
{
|
||||
if ( executionProperties == null )
|
||||
{
|
||||
executionProperties = new Properties();
|
||||
}
|
||||
return executionProperties;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setExecutionProperties( Properties executionProperties )
|
||||
{
|
||||
this.executionProperties = executionProperties;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ModelEventListener> getModelEventListeners()
|
||||
{
|
||||
return listeners;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setModelEventListeners( List<ModelEventListener> listeners )
|
||||
{
|
||||
this.listeners = listeners;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isProcessPlugins()
|
||||
{
|
||||
return processPlugins;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setProcessPlugins( boolean processPlugins )
|
||||
{
|
||||
this.processPlugins = processPlugins;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuildingRequest setLenientValidation( boolean lenientValidation )
|
||||
{
|
||||
this.lenientValidation = lenientValidation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean istLenientValidation()
|
||||
{
|
||||
return lenientValidation;
|
||||
}
|
||||
|
||||
public List<String> getActiveProfileIds()
|
||||
{
|
||||
if ( activeProfileIds == null )
|
||||
{
|
||||
activeProfileIds = new ArrayList<String>();
|
||||
}
|
||||
return activeProfileIds;
|
||||
}
|
||||
|
||||
public void setActiveProfileIds( List<String> activeProfileIds )
|
||||
{
|
||||
this.activeProfileIds = activeProfileIds;
|
||||
}
|
||||
|
||||
public List<String> getInactiveProfileIds()
|
||||
{
|
||||
if ( inactiveProfileIds == null )
|
||||
{
|
||||
inactiveProfileIds = new ArrayList<String>();
|
||||
}
|
||||
return inactiveProfileIds;
|
||||
}
|
||||
|
||||
public void setInactiveProfileIds( List<String> inactiveProfileIds )
|
||||
{
|
||||
this.inactiveProfileIds = inactiveProfileIds;
|
||||
}
|
||||
|
||||
public void setProfiles( List<Profile> profiles )
|
||||
{
|
||||
this.profiles = profiles;
|
||||
}
|
||||
|
||||
public void addProfile( Profile profile )
|
||||
{
|
||||
if ( profiles == null )
|
||||
{
|
||||
profiles = new ArrayList<Profile>();
|
||||
}
|
||||
|
||||
profiles.add( profile );
|
||||
}
|
||||
|
||||
public List<Profile> getProfiles()
|
||||
{
|
||||
if ( profiles == null )
|
||||
{
|
||||
profiles = new ArrayList<Profile>();
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
}
|
|
@ -153,7 +153,7 @@ public class MavenProject
|
|||
|
||||
private ProjectBuilder mavenProjectBuilder;
|
||||
|
||||
private ProjectBuilderConfiguration projectBuilderConfiguration;
|
||||
private ProjectBuildingRequest projectBuilderConfiguration;
|
||||
|
||||
private RepositorySystem repositorySystem;
|
||||
//
|
||||
|
@ -212,7 +212,7 @@ public class MavenProject
|
|||
* @param projectBuilderConfiguration
|
||||
* @throws InvalidRepositoryException
|
||||
*/
|
||||
public MavenProject( Model model, RepositorySystem repositorySystem, ProjectBuilder mavenProjectBuilder, ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
public MavenProject( Model model, RepositorySystem repositorySystem, ProjectBuilder mavenProjectBuilder, ProjectBuildingRequest projectBuilderConfiguration )
|
||||
throws InvalidRepositoryException
|
||||
{
|
||||
if ( model == null )
|
||||
|
@ -291,7 +291,7 @@ public class MavenProject
|
|||
{
|
||||
for ( Iterator<String> it = modules.iterator(); it.hasNext(); )
|
||||
{
|
||||
String modulePath = (String) it.next();
|
||||
String modulePath = it.next();
|
||||
String moduleName = modulePath;
|
||||
|
||||
if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) )
|
||||
|
@ -319,7 +319,7 @@ public class MavenProject
|
|||
}
|
||||
}
|
||||
|
||||
return (String) moduleAdjustments.get( module );
|
||||
return moduleAdjustments.get( module );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -1672,7 +1672,7 @@ public class MavenProject
|
|||
|
||||
public Plugin getPlugin( String pluginKey )
|
||||
{
|
||||
return (Plugin) getBuild().getPluginsAsMap().get( pluginKey );
|
||||
return getBuild().getPluginsAsMap().get( pluginKey );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1904,7 +1904,7 @@ public class MavenProject
|
|||
else
|
||||
{
|
||||
String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
|
||||
MavenProject project = (MavenProject) projectReferences.get( refId );
|
||||
MavenProject project = projectReferences.get( refId );
|
||||
|
||||
boolean projectDirFound = false;
|
||||
if ( project != null )
|
||||
|
|
|
@ -22,16 +22,22 @@ import org.apache.maven.artifact.Artifact;
|
|||
public interface ProjectBuilder
|
||||
{
|
||||
|
||||
MavenProject build( File projectFile, ProjectBuilderConfiguration configuration )
|
||||
MavenProject build( File projectFile, ProjectBuildingRequest request )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject build( Artifact projectArtifact, ProjectBuilderConfiguration configuration )
|
||||
MavenProject build( Artifact projectArtifact, ProjectBuildingRequest request )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
// TODO: this is only to provide a project for plugins that don't need a project to execute but need some
|
||||
// of the values from a MavenProject. Ideally this should be something internal and nothing outside Maven
|
||||
// would ever need this so it should not be exposed in a public API
|
||||
MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration )
|
||||
MavenProject buildStandaloneSuperProject( ProjectBuildingRequest request )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
// TODO: This also doesn't really belong here as it's a mix of project builder and artifact resolution and belongs
|
||||
// in an integration component like the embedder.
|
||||
@Deprecated
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuildingRequest request )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,9 @@ import java.util.Properties;
|
|||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.profile.ProfileActivationContext;
|
||||
|
||||
public interface ProjectBuilderConfiguration
|
||||
extends ProfileActivationContext
|
||||
extends ProjectBuildingRequest
|
||||
{
|
||||
ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository );
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.profile.ProfileActivationContext;
|
||||
|
||||
public interface ProjectBuildingRequest
|
||||
extends ProfileActivationContext
|
||||
{
|
||||
ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository );
|
||||
|
||||
ArtifactRepository getLocalRepository();
|
||||
|
||||
ProjectBuildingRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories );
|
||||
|
||||
List<ArtifactRepository> getRemoteRepositories();
|
||||
|
||||
ProjectBuildingRequest setExecutionProperties( Properties executionProperties );
|
||||
|
||||
Properties getExecutionProperties();
|
||||
|
||||
void setTopLevelProjectForReactor(MavenProject mavenProject);
|
||||
|
||||
MavenProject getTopLevelProjectFromReactor();
|
||||
|
||||
ProjectBuildingRequest 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}.
|
||||
*/
|
||||
ProjectBuildingRequest 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
|
||||
|
||||
/**
|
||||
* Set any active profiles that the {@link ProjectBuilder} should consider while constructing
|
||||
* a {@link MavenProject}.
|
||||
*/
|
||||
void setActiveProfileIds( List<String> activeProfileIds );
|
||||
|
||||
List<String> getActiveProfileIds();
|
||||
|
||||
void setInactiveProfileIds( List<String> inactiveProfileIds );
|
||||
|
||||
List<String> getInactiveProfileIds();
|
||||
|
||||
/**
|
||||
* Add a {@link org.apache.maven.model.Profile} that has come from an external source. This may be from a custom configuration
|
||||
* like the MavenCLI settings.xml file, or from a custom dialog in an IDE integration like M2Eclipse.
|
||||
* @param profile
|
||||
*/
|
||||
void addProfile( Profile profile );
|
||||
|
||||
void setProfiles( List<Profile> profiles );
|
||||
|
||||
List<Profile> getProfiles();
|
||||
}
|
|
@ -37,10 +37,10 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
|||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
@ -107,7 +107,7 @@ public class MavenMetadataSource
|
|||
pomArtifact.setFile( artifact.getFile() );
|
||||
}
|
||||
|
||||
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration();
|
||||
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
|
||||
configuration.setLocalRepository( localRepository );
|
||||
configuration.setRemoteRepositories( remoteRepositories );
|
||||
configuration.setLenientValidation( true );
|
||||
|
|
|
@ -18,9 +18,9 @@ import org.apache.maven.model.Exclusion;
|
|||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.PluginManager;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
@ -103,7 +103,7 @@ public abstract class AbstractCoreMavenComponentTestCase
|
|||
{
|
||||
MavenExecutionRequest request = createMavenExecutionRequest( pom );
|
||||
|
||||
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
|
||||
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest()
|
||||
.setLocalRepository( request.getLocalRepository() )
|
||||
.setRemoteRepositories( request.getRemoteRepositories() );
|
||||
|
||||
|
|
|
@ -1480,7 +1480,7 @@ public class PomConstructionTest
|
|||
pomFile = new File( pomFile, "pom.xml" );
|
||||
}
|
||||
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
|
||||
ProjectBuildingRequest config = new DefaultProjectBuildingRequest();
|
||||
|
||||
String localRepoUrl = System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
||||
localRepoUrl = "file://" + localRepoUrl;
|
||||
|
|
|
@ -8,9 +8,9 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.project.DefaultProjectBuilder;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.ProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingRequest;
|
||||
import org.apache.maven.project.harness.PomTestWrapper;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
@ -73,7 +73,7 @@ public class PomConstructionWithSettingsTest
|
|||
File settingsFile = new File( testDirectory + File.separator + pomPath, "settings.xml" );
|
||||
Settings settings = readSettingsFile(settingsFile);
|
||||
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
|
||||
ProjectBuildingRequest config = new DefaultProjectBuildingRequest();
|
||||
|
||||
for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
|
||||
{
|
||||
|
|
|
@ -34,14 +34,13 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|||
import org.apache.maven.execution.DefaultMavenExecutionResult;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.io.ModelReader;
|
||||
import org.apache.maven.model.io.ModelWriter;
|
||||
import org.apache.maven.plugin.PluginManager;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.MavenProjectBuildingResult;
|
||||
import org.apache.maven.project.ProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.settings.Settings;
|
||||
|
@ -97,9 +96,7 @@ public class MavenEmbedder
|
|||
|
||||
private Maven maven;
|
||||
|
||||
private PluginManager pluginManager;
|
||||
|
||||
private MavenProjectBuilder mavenProjectBuilder;
|
||||
private ProjectBuilder projectBuilder;
|
||||
|
||||
private ModelReader modelReader;
|
||||
|
||||
|
@ -125,8 +122,6 @@ public class MavenEmbedder
|
|||
|
||||
private MavenExecutionRequest request;
|
||||
|
||||
private LifecycleExecutor lifecycleExecutor;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -283,7 +278,7 @@ public class MavenEmbedder
|
|||
{
|
||||
getLogger().debug( "Building MavenProject instance: " + mavenProject );
|
||||
|
||||
return mavenProjectBuilder.build( mavenProject, request.getProjectBuildingConfiguration() );
|
||||
return projectBuilder.build( mavenProject, request.getProjectBuilderRequest() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,7 +308,7 @@ public class MavenEmbedder
|
|||
|
||||
try
|
||||
{
|
||||
MavenProjectBuildingResult projectBuildingResult = mavenProjectBuilder.buildProjectWithDependencies( request.getPom(), request.getProjectBuildingConfiguration() );
|
||||
MavenProjectBuildingResult projectBuildingResult = projectBuilder.buildProjectWithDependencies( request.getPom(), request.getProjectBuilderRequest() );
|
||||
|
||||
result.setProject( projectBuildingResult.getProject() );
|
||||
|
||||
|
@ -398,14 +393,12 @@ public class MavenEmbedder
|
|||
|
||||
maven = container.lookup( Maven.class );
|
||||
|
||||
mavenProjectBuilder = container.lookup( MavenProjectBuilder.class );
|
||||
projectBuilder = container.lookup( ProjectBuilder.class );
|
||||
|
||||
populator = container.lookup( MavenExecutionRequestPopulator.class );
|
||||
|
||||
container.lookup( RepositorySystem.class );
|
||||
|
||||
lifecycleExecutor = container.lookup( LifecycleExecutor.class );
|
||||
|
||||
// This is temporary as we can probably cache a single request and use it for default values and
|
||||
// simply cascade values in from requests used for individual executions.
|
||||
request = new DefaultMavenExecutionRequest();
|
||||
|
|
Loading…
Reference in New Issue