diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java index 015437826d..4116bc5969 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java @@ -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(); - } - } - - 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 ); - } + request.setSettings( embedder.getSettings() ); } - // 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() ); diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/MavenExecutionRequestDefaultsPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/MavenExecutionRequestDefaultsPopulator.java index ca2debdabc..a2d17d5cfd 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/MavenExecutionRequestDefaultsPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/MavenExecutionRequestDefaultsPopulator.java @@ -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; }