Fixing some lingering dependency ordering problems from artifact resolution, and adding settings-builder advice to the CLI.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@512339 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-02-27 17:47:30 +00:00
parent de30bce7f6
commit f4b3eedc8a
7 changed files with 26 additions and 10 deletions

View File

@ -16,8 +16,8 @@ package org.apache.maven.artifact.resolver;
* limitations under the License.
*/
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
/**
@ -39,7 +39,7 @@ public class ArtifactResolutionResult
{
if ( artifacts == null )
{
artifacts = new HashSet();
artifacts = new LinkedHashSet();
for ( Iterator it = resolutionNodes.iterator(); it.hasNext(); )
{
@ -55,7 +55,7 @@ public class ArtifactResolutionResult
{
return resolutionNodes;
}
public void setArtifactResolutionNodes( Set resolutionNodes )
{
this.resolutionNodes = resolutionNodes;

View File

@ -28,9 +28,9 @@ import org.apache.maven.artifact.versioning.VersionRange;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -58,7 +58,7 @@ public class DefaultArtifactCollector
ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
throws ArtifactResolutionException
{
Map resolvedArtifacts = new HashMap();
Map resolvedArtifacts = new LinkedHashMap();
ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories );
@ -67,7 +67,7 @@ public class DefaultArtifactCollector
recurse( root, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source, filter,
listeners );
Set set = new HashSet();
Set set = new LinkedHashSet();
for ( Iterator i = resolvedArtifacts.values().iterator(); i.hasNext(); )
{

View File

@ -24,6 +24,7 @@ import org.apache.maven.embedder.MavenEmbedderException;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.settings.SettingsBuilderAdvice;
import org.codehaus.plexus.classworlds.ClassWorld;
import java.io.File;
@ -314,6 +315,11 @@ public class MavenCli
}
Properties executionProperties = getExecutionProperties( commandLine );
SettingsBuilderAdvice settingsAdvice = new SettingsBuilderAdvice();
settingsAdvice.setDefaultGlobalLocationEnabled( true );
settingsAdvice.setDefaultUserLocationEnabled( true );
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setBaseDirectory( baseDirectory )
@ -326,6 +332,7 @@ public class MavenCli
.setShowErrors( showErrors ) // default: false
// Settings
.setSettingsFile( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) )
.setSettingsBuilderAdvice( settingsAdvice )
//.setLocalRepositoryPath( localRepositoryPath ) // default: ~/.m2/repository
.setInteractiveMode( interactive ) // default: false
.setUsePluginRegistry( usePluginRegistry )

View File

@ -528,9 +528,11 @@ public class DefaultMavenExecutionRequest
return advice;
}
public void setSettingsBuilderAdvice( SettingsBuilderAdvice advice )
public MavenExecutionRequest setSettingsBuilderAdvice( SettingsBuilderAdvice advice )
{
this.advice = advice;
return this;
}
}

View File

@ -193,5 +193,5 @@ public interface MavenExecutionRequest
MavenExecutionRequest setUsePluginUpdateOverride( boolean usePluginUpdateOverride );
SettingsBuilderAdvice getSettingsBuilderAdvice();
void setSettingsBuilderAdvice( SettingsBuilderAdvice advice );
MavenExecutionRequest setSettingsBuilderAdvice( SettingsBuilderAdvice advice );
}

View File

@ -539,7 +539,7 @@ public class MavenProject
public List getTestClasspathElements()
throws DependencyResolutionRequiredException
{
List list = new ArrayList( getArtifacts().size() + 1 );
List list = new ArrayList( getArtifacts().size() + 2 );
list.add( getBuild().getOutputDirectory() );

View File

@ -76,6 +76,8 @@ public class DefaultMavenSettingsBuilder
return new Settings();
}
getLogger().debug( "Reading global settings from: " + globalSettingsFile );
Settings globalSettings = readSettings( globalSettingsFile );
if ( globalSettings == null )
@ -83,6 +85,8 @@ public class DefaultMavenSettingsBuilder
globalSettings = new Settings();
}
getLogger().debug( "Reading user settings from: " + userSettingsFile );
Settings userSettings = readSettings( userSettingsFile );
if ( userSettings == null )
@ -124,6 +128,7 @@ public class DefaultMavenSettingsBuilder
{
if ( settingsFile == null )
{
getLogger().debug( "Settings file is null. Returning." );
return null;
}
@ -131,6 +136,8 @@ public class DefaultMavenSettingsBuilder
if ( settingsFile.exists() && settingsFile.isFile() )
{
getLogger().debug( "Settings file is a proper file. Reading." );
FileReader reader = null;
try
{