mirror of https://github.com/apache/maven.git
o we'll use the embedder now for some default values because we still have an asymmetry for many of the methods that
don't use an execution request, or configuration, but require direct use of things like settings and the local repository. an example being the profile manager. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@512541 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
513e42d79d
commit
6edbabf67f
|
@ -23,8 +23,11 @@ import org.apache.maven.MavenTools;
|
|||
import org.apache.maven.SettingsConfigurationException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.embedder.MavenEmbedderConfiguration;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.embedder.configuration.Configuration;
|
||||
import org.apache.maven.embedder.MavenEmbedderException;
|
||||
import org.apache.maven.embedder.MavenEmbedder;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
||||
import org.apache.maven.plugin.Mojo;
|
||||
|
@ -44,6 +47,7 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
@ -57,68 +61,25 @@ public class DefaultMavenExecutionRequestDefaultsPopulator
|
|||
extends AbstractLogEnabled
|
||||
implements MavenExecutionRequestDefaultsPopulator, Contextualizable
|
||||
{
|
||||
private MavenTools mavenTools;
|
||||
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
|
||||
|
||||
private PlexusContainer container;
|
||||
|
||||
private WagonManager wagonManager;
|
||||
|
||||
public MavenExecutionRequest populateDefaults( MavenExecutionRequest request, MavenEmbedderConfiguration embedderConfiguration )
|
||||
public MavenExecutionRequest populateDefaults( MavenExecutionRequest request, MavenEmbedder embedder )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
// Settings
|
||||
|
||||
if ( request.getSettings() == null )
|
||||
{
|
||||
// A local repository set in the request should win over what's in a settings.xml file.
|
||||
String userSettingsLocation = request.getSettingsFile();
|
||||
if ( userSettingsLocation == null )
|
||||
{
|
||||
File userSettingsFile = embedderConfiguration.getUserSettingsFile();
|
||||
if ( userSettingsFile != null )
|
||||
{
|
||||
userSettingsLocation = userSettingsFile.getAbsolutePath();
|
||||
request.setSettings( embedder.getSettings() );
|
||||
}
|
||||
}
|
||||
|
||||
File userSettingsPath = null; //mavenTools.getUserSettingsPath( userSettingsLocation );
|
||||
if ( userSettingsLocation != null )
|
||||
{
|
||||
userSettingsPath = new File( userSettingsLocation );
|
||||
}
|
||||
|
||||
File globalSettingsFile = null; //mavenTools.getGlobalSettingsPath();
|
||||
|
||||
File configGlobalSettings = embedderConfiguration.getGlobalSettingsFile();
|
||||
if ( configGlobalSettings != null )
|
||||
{
|
||||
globalSettingsFile = configGlobalSettings;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
request.setSettings( mavenTools.buildSettings( userSettingsPath, globalSettingsFile, request
|
||||
.isInteractiveMode(), request.isOffline(), request.isUsePluginRegistry(), request
|
||||
.isUsePluginUpdateOverride(), request.getSettingsBuilderAdvice() ) );
|
||||
}
|
||||
catch ( SettingsConfigurationException e )
|
||||
{
|
||||
throw new MavenEmbedderException( "Error processing settings.xml.", e );
|
||||
}
|
||||
}
|
||||
|
||||
// Local repository
|
||||
|
||||
if ( request.getLocalRepository() == null )
|
||||
{
|
||||
String localRepositoryPath = mavenTools.getLocalRepositoryPath( request.getSettings() );
|
||||
|
||||
if ( request.getLocalRepository() == null )
|
||||
{
|
||||
request.setLocalRepository( mavenTools.createLocalRepository( new File( localRepositoryPath ) ) );
|
||||
}
|
||||
request.setLocalRepository( embedder.getLocalRepository() );
|
||||
}
|
||||
|
||||
// Repository update policies
|
||||
|
@ -149,7 +110,7 @@ public class DefaultMavenExecutionRequestDefaultsPopulator
|
|||
|
||||
wagonManager.setOnline( !request.isOffline() );
|
||||
|
||||
if ( request.getSettings().isOffline() )
|
||||
if ( request.isOffline() )
|
||||
{
|
||||
getLogger().info( SystemWarnings.getOfflineWarning() );
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package org.apache.maven.embedder.execution;
|
||||
|
||||
import org.apache.maven.embedder.MavenEmbedderConfiguration;
|
||||
import org.apache.maven.embedder.configuration.Configuration;
|
||||
import org.apache.maven.embedder.MavenEmbedderException;
|
||||
import org.apache.maven.embedder.MavenEmbedder;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
|
||||
public interface MavenExecutionRequestDefaultsPopulator
|
||||
{
|
||||
String ROLE = MavenExecutionRequestDefaultsPopulator.class.getName();
|
||||
|
||||
MavenExecutionRequest populateDefaults( MavenExecutionRequest request, MavenEmbedderConfiguration embedderConfiguration )
|
||||
MavenExecutionRequest populateDefaults( MavenExecutionRequest request, MavenEmbedder embedder )
|
||||
throws MavenEmbedderException;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue