diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java
index b1e34888e1..255573d281 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java
@@ -18,7 +18,6 @@ package org.apache.maven.artifact.repository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Repository;
-import org.apache.maven.settings.Settings;
/**
* @author jdcasey
@@ -28,7 +27,7 @@ public interface ArtifactRepositoryFactory
public static final String ROLE = ArtifactRepositoryFactory.class.getName();
- public ArtifactRepository createArtifactRepository( Repository modelRepository, Settings settings,
+ public ArtifactRepository createArtifactRepository( Repository modelRepository,
ArtifactRepositoryLayout repositoryLayout );
void setGlobalSnapshotPolicy( String snapshotPolicy );
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
index 04a878ab7d..dad5036186 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
@@ -20,9 +20,13 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Repository;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.Server;
+import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
/**
* @author jdcasey
@@ -31,17 +35,36 @@ public class DefaultArtifactRepositoryFactory
extends AbstractLogEnabled
implements ArtifactRepositoryFactory
{
+ // TODO: use settings?
private String globalSnapshotPolicy = null;
- public ArtifactRepository createArtifactRepository( Repository modelRepository, Settings settings,
+ // TODO: make this a store once object?
+ private MavenSettingsBuilder settingsBuilder;
+
+ public ArtifactRepository createArtifactRepository( Repository modelRepository,
ArtifactRepositoryLayout repositoryLayout )
{
+
Server repoProfile = null;
String repoId = modelRepository.getId();
if ( repoId != null && repoId.length() > 0 )
{
+ Settings settings = null;
+ try
+ {
+ settings = settingsBuilder.buildSettings();
+ }
+ catch ( IOException e )
+ {
+ getLogger().warn( "Error reading settings", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ getLogger().warn( "Error reading settings", e );
+ }
+
repoProfile = settings.getServer( modelRepository.getId() );
}
else
diff --git a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
index 0540665606..340ffa6ccc 100644
--- a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -503,6 +503,6 @@ public class MavenCli
repo.setUrl( "file://" + profile.getLocalRepository() );
- return repoFactory.createArtifactRepository( repo, settings, repositoryLayout );
+ return repoFactory.createArtifactRepository( repo, repositoryLayout );
}
}
\ No newline at end of file
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
index 6699601183..1666774945 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
@@ -38,8 +38,6 @@ import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
-import org.apache.maven.settings.MavenSettingsBuilder;
-import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -91,8 +89,6 @@ public class DefaultMavenProjectBuilder
private ModelInterpolator modelInterpolator;
- private MavenSettingsBuilder mavenSettingsBuilder;
-
private ArtifactRepositoryFactory artifactRepositoryFactory;
private final Map modelCache = new HashMap();
@@ -129,10 +125,6 @@ public class DefaultMavenProjectBuilder
// Always cache files in the source tree over those in the repository
modelCache.put( createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ), model );
- Settings settings = readSettings();
-
- boolean systemOnline = !settings.getActiveProfile().isOffline();
-
MavenProject project = build( model, localRepository, resolveDependencies );
// Only translate the base directory for files in the source tree
@@ -149,32 +141,6 @@ public class DefaultMavenProjectBuilder
return project;
}
- /**
- * @return
- * @throws ProjectBuildingException
- * @todo shouldn't be re-reading all the time - perhaps cache, but check a timestamp so you can detect and reload on
- * changes in a long running process
- */
- private Settings readSettings()
- throws ProjectBuildingException
- {
- Settings settings = null;
-
- try
- {
- settings = mavenSettingsBuilder.buildSettings();
- }
- catch ( IOException e )
- {
- throw new ProjectBuildingException( "Cannot read settings.", e );
- }
- catch ( XmlPullParserException e )
- {
- throw new ProjectBuildingException( "Cannot read settings.", e );
- }
- return settings;
- }
-
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository )
throws ProjectBuildingException
@@ -370,7 +336,6 @@ public class DefaultMavenProjectBuilder
private List buildArtifactRepositories( List repositories )
throws ProjectBuildingException
{
- Settings settings = readSettings();
List repos = new ArrayList();
@@ -380,7 +345,7 @@ public class DefaultMavenProjectBuilder
ArtifactRepositoryLayout remoteRepoLayout = getRepositoryLayout( mavenRepo );
- ArtifactRepository artifactRepo = artifactRepositoryFactory.createArtifactRepository( mavenRepo, settings,
+ ArtifactRepository artifactRepo = artifactRepositoryFactory.createArtifactRepository( mavenRepo,
remoteRepoLayout );
if ( !repos.contains( artifactRepo ) )
@@ -396,8 +361,6 @@ public class DefaultMavenProjectBuilder
{
List remotePluginRepositories = new ArrayList();
- Settings settings = readSettings();
-
for ( Iterator it = pluginRepositories.iterator(); it.hasNext(); )
{
Repository mavenRepo = (Repository) it.next();
@@ -405,7 +368,6 @@ public class DefaultMavenProjectBuilder
ArtifactRepositoryLayout repositoryLayout = getRepositoryLayout( mavenRepo );
ArtifactRepository pluginRepository = artifactRepositoryFactory.createArtifactRepository( mavenRepo,
- settings,
repositoryLayout );
remotePluginRepositories.add( pluginRepository );
@@ -441,11 +403,9 @@ public class DefaultMavenProjectBuilder
return null;
}
- Settings settings = readSettings();
-
ArtifactRepositoryLayout repositoryLayout = getRepositoryLayout( dmRepo );
- ArtifactRepository dmArtifactRepository = artifactRepositoryFactory.createArtifactRepository( dmRepo, settings,
+ ArtifactRepository dmArtifactRepository = artifactRepositoryFactory.createArtifactRepository( dmRepo,
repositoryLayout );
return dmArtifactRepository;
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
index ff492f1a6c..9d416e8312 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
@@ -19,6 +19,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.settings.Settings;
import java.io.File;
import java.util.List;
diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml
index c3ffd68d55..c7acd3e0df 100644
--- a/maven-core/src/main/resources/META-INF/plexus/components.xml
+++ b/maven-core/src/main/resources/META-INF/plexus/components.xml
@@ -89,9 +89,6 @@
org.apache.maven.artifact.repository.ArtifactRepositoryFactory
-
- org.apache.maven.settings.MavenSettingsBuilder
-