mirror of https://github.com/apache/maven.git
MNG-3905 First pass at collecting all the repository related code and started to decouple from maven-artifact
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@726383 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4074068126
commit
ea43792cf2
|
@ -558,17 +558,21 @@ public class DefaultPluginManager
|
|||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||
|
||||
Xpp3Dom dom = mojoExecution.getConfiguration();
|
||||
|
||||
if ( dom != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
|
||||
|
||||
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( session.getProjectBuilderConfiguration().getExecutionProperties(),
|
||||
PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
|
||||
|
||||
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( session.getProjectBuilderConfiguration().getUserProperties(),
|
||||
PomInterpolatorTag.USER_PROPERTIES.name()));
|
||||
String interpolatedDom =
|
||||
Interpolator.interpolateXmlString( String.valueOf( dom ), interpolatorProperties );
|
||||
|
||||
String interpolatedDom = Interpolator.interpolateXmlString( String.valueOf( dom ), interpolatorProperties );
|
||||
|
||||
dom = Xpp3DomBuilder.build( new StringReader( interpolatedDom ) );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
|
|
|
@ -26,11 +26,10 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.Maven;
|
||||
import org.apache.maven.MavenTools;
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.embedder.Configuration;
|
||||
import org.apache.maven.embedder.MavenEmbedder;
|
||||
import org.apache.maven.embedder.MavenEmbedderException;
|
||||
|
@ -53,15 +52,11 @@ import org.apache.maven.settings.Settings;
|
|||
import org.apache.maven.settings.SettingsConfigurationException;
|
||||
import org.apache.maven.settings.SettingsUtils;
|
||||
import org.apache.maven.wagon.repository.RepositoryPermissions;
|
||||
import org.codehaus.plexus.MutablePlexusContainer;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.context.Context;
|
||||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
@ -85,12 +80,6 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
extends AbstractLogEnabled
|
||||
implements MavenExecutionRequestPopulator
|
||||
{
|
||||
@Requirement
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
@Requirement
|
||||
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
|
||||
|
||||
@Requirement
|
||||
private PlexusContainer container;
|
||||
|
||||
|
@ -100,6 +89,9 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
@Requirement
|
||||
private MavenSettingsBuilder settingsBuilder;
|
||||
|
||||
@Requirement
|
||||
private MavenTools mavenTools;
|
||||
|
||||
public MavenExecutionRequest populateDefaults( MavenExecutionRequest request,
|
||||
Configuration configuration )
|
||||
throws MavenEmbedderException
|
||||
|
@ -259,8 +251,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
snapshots.setUpdatePolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
||||
}
|
||||
|
||||
ArtifactRepository ar = artifactRepositoryFactory.createArtifactRepository( r.getId(), r.getUrl(),
|
||||
defaultArtifactRepositoryLayout, snapshots, releases );
|
||||
ArtifactRepository ar = mavenTools.createRepository( r.getId(), r.getUrl(), snapshots, releases );
|
||||
|
||||
request.addRemoteRepository( ar );
|
||||
}
|
||||
|
@ -347,10 +338,6 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Local Repository
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private void localRepository( MavenExecutionRequest request,
|
||||
Configuration configuration )
|
||||
throws MavenEmbedderException
|
||||
|
@ -368,119 +355,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
request.setLocalRepository( createLocalRepository( request, request.getSettings(), configuration ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ArtifactRepository createLocalRepository( MavenExecutionRequest request,
|
||||
Settings settings,
|
||||
Configuration configuration )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
String localRepositoryPath = null;
|
||||
|
||||
if ( request.getLocalRepositoryPath() != null )
|
||||
{
|
||||
localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) && ( configuration.getLocalRepository() != null ) )
|
||||
{
|
||||
localRepositoryPath = configuration.getLocalRepository().getAbsolutePath();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) )
|
||||
{
|
||||
localRepositoryPath = settings.getLocalRepository();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) )
|
||||
{
|
||||
localRepositoryPath = MavenEmbedder.defaultUserLocalRepository.getAbsolutePath();
|
||||
}
|
||||
|
||||
return createLocalRepository(
|
||||
localRepositoryPath,
|
||||
MavenEmbedder.DEFAULT_LOCAL_REPO_ID );
|
||||
}
|
||||
|
||||
public ArtifactRepository createLocalRepository( String url,
|
||||
String repositoryId )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
try
|
||||
{
|
||||
return createRepository(
|
||||
canonicalFileUrl( url ),
|
||||
repositoryId );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MavenEmbedderException(
|
||||
"Unable to resolve canonical path for local repository " + url,
|
||||
e );
|
||||
}
|
||||
}
|
||||
|
||||
private String canonicalFileUrl( String url )
|
||||
throws IOException
|
||||
{
|
||||
if ( !url.startsWith( "file:" ) )
|
||||
{
|
||||
url = "file://" + url;
|
||||
}
|
||||
else if ( url.startsWith( "file:" ) && !url.startsWith( "file://" ) )
|
||||
{
|
||||
url = "file://" + url.substring( "file:".length() );
|
||||
}
|
||||
|
||||
// So now we have an url of the form file://<path>
|
||||
|
||||
// We want to eliminate any relative path nonsense and lock down the path so we
|
||||
// need to fully resolve it before any sub-modules use the path. This can happen
|
||||
// when you are using a custom settings.xml that contains a relative path entry
|
||||
// for the local repository setting.
|
||||
|
||||
File localRepository = new File( url.substring( "file://".length() ) );
|
||||
|
||||
if ( !localRepository.isAbsolute() )
|
||||
{
|
||||
url = "file://" + localRepository.getCanonicalPath();
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public ArtifactRepository createRepository( String url,
|
||||
String repositoryId )
|
||||
{
|
||||
// snapshots vs releases
|
||||
// offline = to turning the update policy off
|
||||
|
||||
//TODO: we'll need to allow finer grained creation of repositories but this will do for now
|
||||
|
||||
String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS;
|
||||
|
||||
String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
|
||||
|
||||
ArtifactRepositoryPolicy snapshotsPolicy =
|
||||
new ArtifactRepositoryPolicy(
|
||||
true,
|
||||
updatePolicyFlag,
|
||||
checksumPolicyFlag );
|
||||
|
||||
ArtifactRepositoryPolicy releasesPolicy =
|
||||
new ArtifactRepositoryPolicy(
|
||||
true,
|
||||
updatePolicyFlag,
|
||||
checksumPolicyFlag );
|
||||
|
||||
return artifactRepositoryFactory.createArtifactRepository(
|
||||
repositoryId,
|
||||
url,
|
||||
defaultArtifactRepositoryLayout,
|
||||
snapshotsPolicy,
|
||||
releasesPolicy );
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Snapshot Policy
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -505,12 +380,12 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
{
|
||||
if ( request.isUpdateSnapshots() )
|
||||
{
|
||||
artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
|
||||
mavenTools.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
|
||||
}
|
||||
else if ( request.isNoSnapshotUpdates() )
|
||||
{
|
||||
getLogger().info( "+ Supressing SNAPSHOT updates." );
|
||||
artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER );
|
||||
mavenTools.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +403,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
// We take the checksum passed in via the request.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() );
|
||||
mavenTools.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -626,7 +501,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
}
|
||||
|
||||
RepositoryPermissions defaultPermissions = new RepositoryPermissions();
|
||||
|
||||
|
||||
defaultPermissions.setDirectoryMode( "775" );
|
||||
|
||||
defaultPermissions.setFileMode( "664" );
|
||||
|
@ -649,6 +524,43 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
}
|
||||
}
|
||||
|
||||
public ArtifactRepository createLocalRepository( MavenExecutionRequest request,
|
||||
Settings settings,
|
||||
Configuration configuration )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
String localRepositoryPath = null;
|
||||
|
||||
if ( request.getLocalRepositoryPath() != null )
|
||||
{
|
||||
localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) && ( configuration.getLocalRepository() != null ) )
|
||||
{
|
||||
localRepositoryPath = configuration.getLocalRepository().getAbsolutePath();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) )
|
||||
{
|
||||
localRepositoryPath = settings.getLocalRepository();
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( localRepositoryPath ) )
|
||||
{
|
||||
localRepositoryPath = MavenEmbedder.defaultUserLocalRepository.getAbsolutePath();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return mavenTools.createLocalRepository( localRepositoryPath, MavenEmbedder.DEFAULT_LOCAL_REPO_ID );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MavenEmbedderException( "Cannot create local repository.", e );
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Eventing
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -689,15 +601,12 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
{
|
||||
// ------------------------------------------------------------------------
|
||||
// Profile Manager
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ProfileActivationContext activationContext = request.getProfileActivationContext();
|
||||
if ( activationContext == null )
|
||||
{
|
||||
activationContext = new DefaultProfileActivationContext(
|
||||
request.getProperties(), false );
|
||||
activationContext = new DefaultProfileActivationContext( request.getProperties(), false );
|
||||
}
|
||||
|
||||
activationContext.setExplicitlyActiveProfileIds( request.getActiveProfiles() );
|
||||
|
|
|
@ -169,13 +169,16 @@ public class PomTransformer
|
|||
}
|
||||
}
|
||||
|
||||
List<ModelProperty> pList = new ArrayList<ModelProperty>();
|
||||
List<ModelProperty> pList;
|
||||
|
||||
if ( !hasExecutionsTag )
|
||||
{
|
||||
pList = managementContainer.getProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
pList = new ArrayList<ModelProperty>();
|
||||
|
||||
for ( ModelProperty mp : managementContainer.getProperties() )
|
||||
{
|
||||
if ( !mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) )
|
||||
|
@ -191,8 +194,8 @@ public class PomTransformer
|
|||
|
||||
if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) )
|
||||
{
|
||||
ModelDataSource dependencyDatasource = new DefaultModelDataSource();
|
||||
dependencyDatasource.init( pluginContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
|
||||
ModelDataSource pluginDatasource = new DefaultModelDataSource();
|
||||
pluginDatasource.init( pluginContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
|
||||
new IdModelContainerFactory() ) );
|
||||
|
||||
ModelDataSource managementDatasource = new DefaultModelDataSource();
|
||||
|
@ -208,12 +211,12 @@ public class PomTransformer
|
|||
|
||||
source.join( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) );
|
||||
|
||||
List<ModelContainer> dependencyExecutionContainers = dependencyDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
|
||||
List<ModelContainer> pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
|
||||
List<ModelContainer> joinedExecutionContainers = new ArrayList<ModelContainer>();
|
||||
|
||||
for(ModelContainer a : managementExecutionContainers)
|
||||
{
|
||||
for(ModelContainer b : dependencyExecutionContainers)
|
||||
for(ModelContainer b : pluginExecutionContainers)
|
||||
{
|
||||
if(b.containerAction(a).equals(ModelContainerAction.JOIN))
|
||||
{
|
||||
|
@ -269,8 +272,8 @@ public class PomTransformer
|
|||
ModelDataSource executionSource = new DefaultModelDataSource();
|
||||
executionSource.init( pluginContainer.getProperties(),
|
||||
Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) );
|
||||
List<ModelContainer> executionContainers =
|
||||
executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
||||
List<ModelContainer> executionContainers = executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
||||
|
||||
if ( executionContainers.size() < 2 )
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.maven;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -27,6 +29,7 @@ import org.apache.maven.artifact.InvalidRepositoryException;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.RepositoryPolicy;
|
||||
|
@ -44,6 +47,9 @@ public class DefaultMavenTools
|
|||
@Requirement
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
@Requirement
|
||||
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Code snagged from ProjectUtils: this will have to be moved somewhere else
|
||||
// but just trying to collect it all in one place right now.
|
||||
|
@ -140,4 +146,78 @@ public class DefaultMavenTools
|
|||
|
||||
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
|
||||
}
|
||||
|
||||
// From MavenExecutionRequestPopulator
|
||||
|
||||
public ArtifactRepository createLocalRepository( String url, String repositoryId )
|
||||
throws IOException
|
||||
{
|
||||
return createRepository( canonicalFileUrl( url ), repositoryId );
|
||||
}
|
||||
|
||||
private String canonicalFileUrl( String url )
|
||||
throws IOException
|
||||
{
|
||||
if ( !url.startsWith( "file:" ) )
|
||||
{
|
||||
url = "file://" + url;
|
||||
}
|
||||
else if ( url.startsWith( "file:" ) && !url.startsWith( "file://" ) )
|
||||
{
|
||||
url = "file://" + url.substring( "file:".length() );
|
||||
}
|
||||
|
||||
// So now we have an url of the form file://<path>
|
||||
|
||||
// We want to eliminate any relative path nonsense and lock down the path so we
|
||||
// need to fully resolve it before any sub-modules use the path. This can happen
|
||||
// when you are using a custom settings.xml that contains a relative path entry
|
||||
// for the local repository setting.
|
||||
|
||||
File localRepository = new File( url.substring( "file://".length() ) );
|
||||
|
||||
if ( !localRepository.isAbsolute() )
|
||||
{
|
||||
url = "file://" + localRepository.getCanonicalPath();
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public ArtifactRepository createRepository( String url,
|
||||
String repositoryId )
|
||||
{
|
||||
// snapshots vs releases
|
||||
// offline = to turning the update policy off
|
||||
|
||||
//TODO: we'll need to allow finer grained creation of repositories but this will do for now
|
||||
|
||||
String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS;
|
||||
|
||||
String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
|
||||
|
||||
ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
|
||||
|
||||
ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag );
|
||||
|
||||
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
||||
}
|
||||
|
||||
public ArtifactRepository createRepository( String url,
|
||||
String repositoryId,
|
||||
ArtifactRepositoryPolicy snapshotsPolicy,
|
||||
ArtifactRepositoryPolicy releasesPolicy )
|
||||
{
|
||||
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
||||
}
|
||||
|
||||
public void setGlobalUpdatePolicy( String policy )
|
||||
{
|
||||
artifactRepositoryFactory.setGlobalUpdatePolicy( policy );
|
||||
}
|
||||
|
||||
public void setGlobalChecksumPolicy( String policy )
|
||||
{
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( policy );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,12 @@ package org.apache.maven;
|
|||
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.model.Repository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -45,4 +48,15 @@ public interface MavenTools
|
|||
|
||||
ArtifactRepository buildArtifactRepository( Repository repo )
|
||||
throws InvalidRepositoryException;
|
||||
|
||||
ArtifactRepository createLocalRepository( String url, String repositoryId )
|
||||
throws IOException;
|
||||
|
||||
ArtifactRepository createRepository( String url, String repositoryId );
|
||||
|
||||
ArtifactRepository createRepository( String url, String repositoryId, ArtifactRepositoryPolicy snapshotsPolicy, ArtifactRepositoryPolicy releasesPolicy );
|
||||
|
||||
void setGlobalUpdatePolicy( String policy );
|
||||
|
||||
void setGlobalChecksumPolicy( String policy );
|
||||
}
|
||||
|
|
|
@ -74,15 +74,6 @@ public class DefaultMavenProjectBuilder
|
|||
@Requirement
|
||||
protected MavenProfilesBuilder profilesBuilder;
|
||||
|
||||
@Requirement
|
||||
protected ArtifactResolver artifactResolver;
|
||||
|
||||
@Requirement
|
||||
protected ArtifactMetadataSource artifactMetadataSource;
|
||||
|
||||
@Requirement
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
@Requirement
|
||||
private ModelValidator validator;
|
||||
|
||||
|
@ -101,6 +92,15 @@ public class DefaultMavenProjectBuilder
|
|||
private MavenXpp3Reader modelReader;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
@Requirement
|
||||
protected ArtifactResolver artifactResolver;
|
||||
|
||||
@Requirement
|
||||
protected ArtifactMetadataSource artifactMetadataSource;
|
||||
|
||||
@Requirement
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
//DO NOT USE, it is here only for backward compatibility reasons. The existing
|
||||
// maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.
|
||||
|
@ -135,22 +135,21 @@ public class DefaultMavenProjectBuilder
|
|||
public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(
|
||||
config.getLocalRepository(), repositoryHelper.buildArtifactRepositories(
|
||||
getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
|
||||
MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver( config.getLocalRepository(), repositoryHelper
|
||||
.buildArtifactRepositories( getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
|
||||
|
||||
project.setFile( projectDescriptor );
|
||||
project = buildWithProfiles( project.getModel(), config, projectDescriptor, project.getParentFile(), true );
|
||||
project.setFile( projectDescriptor );
|
||||
project = buildWithProfiles( project.getModel(), config, projectDescriptor, project.getParentFile(), true );
|
||||
|
||||
Build build = project.getBuild();
|
||||
// NOTE: setting this script-source root before path translation, because
|
||||
// the plugin tools compose basedir and scriptSourceRoot into a single file.
|
||||
project.addScriptSourceRoot( build.getScriptSourceDirectory() );
|
||||
project.addCompileSourceRoot( build.getSourceDirectory() );
|
||||
project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
|
||||
project.setFile( projectDescriptor );
|
||||
Build build = project.getBuild();
|
||||
// NOTE: setting this script-source root before path translation, because
|
||||
// the plugin tools compose basedir and scriptSourceRoot into a single file.
|
||||
project.addScriptSourceRoot( build.getScriptSourceDirectory() );
|
||||
project.addCompileSourceRoot( build.getSourceDirectory() );
|
||||
project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
|
||||
project.setFile( projectDescriptor );
|
||||
|
||||
setBuildOutputDirectoryOnParent( project );
|
||||
setBuildOutputDirectoryOnParent( project );
|
||||
return project;
|
||||
}
|
||||
|
||||
|
@ -189,8 +188,7 @@ public class DefaultMavenProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
File f = (artifact.getFile() != null) ? artifact.getFile() :
|
||||
new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );;
|
||||
File f = (artifact.getFile() != null) ? artifact.getFile() : new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
|
||||
|
@ -200,7 +198,6 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
|
||||
project = buildWithProfiles( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
|
||||
// project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
|
||||
artifact.setFile( f );
|
||||
project.setVersion( artifact.getVersion() );
|
||||
|
||||
|
@ -242,8 +239,10 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
|
||||
List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
|
||||
|
||||
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getExecutionProperties(),
|
||||
PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
|
||||
|
||||
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getUserProperties(),
|
||||
PomInterpolatorTag.USER_PROPERTIES.name()));
|
||||
|
||||
|
@ -482,6 +481,7 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
|
||||
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
|
||||
|
||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||
|
||||
Reader reader = null;
|
||||
|
@ -492,13 +492,13 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
if ( modelSource.indexOf( "<modelVersion>" + MAVEN_MODEL_VERSION ) < 0 )
|
||||
{
|
||||
throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.",
|
||||
new File( "." ) );
|
||||
throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.", new File( "." ) );
|
||||
}
|
||||
|
||||
StringReader sReader = new StringReader( modelSource );
|
||||
|
||||
superModel = modelReader.read( sReader, STRICT_MODEL_PARSING );
|
||||
|
||||
return superModel;
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
|
@ -526,14 +526,11 @@ public class DefaultMavenProjectBuilder
|
|||
throw new IllegalArgumentException( "projectDescriptor: null, Project Id =" + projectId );
|
||||
}
|
||||
|
||||
if ( projectBuilder == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "projectBuilder: not initialized" );
|
||||
}
|
||||
|
||||
List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
|
||||
|
||||
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getExecutionProperties(),
|
||||
PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
|
||||
|
||||
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getUserProperties(),
|
||||
PomInterpolatorTag.USER_PROPERTIES.name()));
|
||||
|
||||
|
@ -545,13 +542,19 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
|
||||
interpolatorProperties.add(new InterpolatorProperty("${mavenVersion}", MavenProjectBuilder.STANDALONE_SUPERPOM_VERSION, PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
|
||||
|
||||
MavenProject mavenProject;
|
||||
|
||||
try
|
||||
{
|
||||
mavenProject = projectBuilder.buildFromLocalPath( new FileInputStream( projectDescriptor ), Arrays.asList(
|
||||
getSuperProject( config, projectDescriptor, true ).getModel() ), null, interpolatorProperties, resolver,
|
||||
projectDescriptor.getParentFile(),
|
||||
config );
|
||||
mavenProject = projectBuilder.buildFromLocalPath( new FileInputStream( projectDescriptor ),
|
||||
Arrays.asList(
|
||||
getSuperProject( config, projectDescriptor, true ).getModel() ),
|
||||
null,
|
||||
interpolatorProperties,
|
||||
resolver,
|
||||
projectDescriptor.getParentFile(),
|
||||
config );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -37,21 +37,20 @@ public interface MavenProjectBuilder
|
|||
// site
|
||||
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
||||
// remote resources plugin
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStub )
|
||||
throws ProjectBuildingException;
|
||||
//
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject build( File project, ProjectBuilderConfiguration configuration )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration config )
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration configuration )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
|
||||
MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration )
|
||||
throws ProjectBuildingException;
|
||||
}
|
||||
|
|
40
pom.xml
40
pom.xml
|
@ -46,44 +46,6 @@ under the License.
|
|||
<system>jira</system>
|
||||
<url>http://jira.codehaus.org/browse/MNG</url>
|
||||
</issueManagement>
|
||||
|
||||
<!-- TODO: TAKE THIS OUT BEFORE WE RELEASE! -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype.snapshots</id>
|
||||
<url>http://repository.sonatype.org/service/local/repositories/snapshots/content/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype.releases</id>
|
||||
<url>http://repository.sonatype.org/service/local/repositories/releases/content/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>apache.snapshots</id>
|
||||
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codehaus.snapshots</id>
|
||||
<url>http://snapshots.repository.codehaus.org/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>Maven Developer List</name>
|
||||
|
@ -297,7 +259,7 @@ under the License.
|
|||
<plexusUtilsVersion>1.5.5</plexusUtilsVersion>
|
||||
<wagonVersion>1.0-beta-4</wagonVersion>
|
||||
<mavenSharedModel>1.0-SNAPSHOT</mavenSharedModel>
|
||||
<mercuryVersion>1.0.0-alpha-2-SNAPSHOT</mercuryVersion>
|
||||
<mercuryVersion>1.0.0-alpha-2</mercuryVersion>
|
||||
<woodstoxVersion>3.2.6</woodstoxVersion>
|
||||
<modelloVersion>1.0-alpha-22</modelloVersion>
|
||||
</properties>
|
||||
|
|
Loading…
Reference in New Issue