You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ma...@apache.org on 2007/06/28 18:26:17 UTC

svn commit: r551613 [1/2] - in /maven/components/branches/MNG-612: maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/ maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/ maven-artifact-manager/src/mai...

Author: markh
Date: Thu Jun 28 09:26:15 2007
New Revision: 551613

URL: http://svn.apache.org/viewvc?view=rev&rev=551613
Log:
[MNG-612] implement conflict resolution techniques

Initial implementation.

Added:
    maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/
    maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java   (with props)
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java   (with props)
Modified:
    maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
    maven/components/branches/MNG-612/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java
    maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java
    maven/components/branches/MNG-612/maven-artifact/src/main/resources/META-INF/plexus/components.xml
    maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
    maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
    maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/branches/MNG-612/maven-core/src/main/resources/META-INF/plexus/components.xml
    maven/components/branches/MNG-612/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/branches/MNG-612/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
    maven/components/branches/MNG-612/maven-project/src/main/resources/META-INF/plexus/components.xml

Modified: maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (original)
+++ maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java Thu Jun 28 09:26:15 2007
@@ -260,17 +260,8 @@
                                                          ArtifactFilter filter )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        // TODO: this is simplistic
-        List listeners = new ArrayList();
-        if ( getLogger().isDebugEnabled() )
-        {
-            listeners.add( new DebugResolutionListener( getLogger() ) );
-        }
-
-        listeners.add( new WarningResolutionListener( getLogger() ) );
-
         return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
-                                    remoteRepositories, source, filter, listeners );
+                                    remoteRepositories, source, filter, null );
 
     }
 
@@ -280,10 +271,32 @@
                                                          ArtifactFilter filter, List listeners )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
+        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
+                                    remoteRepositories, source, filter, listeners, null );
+    }
+    
+    public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
+                                                         Map managedVersions, ArtifactRepository localRepository,
+                                                         List remoteRepositories, ArtifactMetadataSource source,
+                                                         ArtifactFilter filter, List listeners, List conflictResolvers )
+        throws ArtifactResolutionException, ArtifactNotFoundException
+    {
+        if ( listeners == null )
+        {
+            // TODO: this is simplistic
+            listeners = new ArrayList();
+            if ( getLogger().isDebugEnabled() )
+            {
+                listeners.add( new DebugResolutionListener( getLogger() ) );
+            }
+
+            listeners.add( new WarningResolutionListener( getLogger() ) );
+        }
+
         ArtifactResolutionResult artifactResolutionResult;
         artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, managedVersions,
                                                               localRepository, remoteRepositories, source, filter,
-                                                              listeners );
+                                                              listeners, conflictResolvers );
 
         List missingArtifacts = new ArrayList();
         for ( Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i.hasNext(); )

Added: maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java (added)
+++ maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,71 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+
+/**
+ * A conflict resolver factory that obtains instances from a plexus container.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @since 2.0.8
+ */
+public class DefaultConflictResolverFactory implements ConflictResolverFactory, Contextualizable
+{
+    // fields -----------------------------------------------------------------
+
+    /**
+     * The plexus container used to obtain instances from.
+     */
+    private PlexusContainer container;
+    
+    // ConflictResolverFactory methods ----------------------------------------
+    
+    /*
+     * @see org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory#getConflictResolver(java.lang.String)
+     */
+    public ConflictResolver getConflictResolver( String type ) throws ConflictResolverNotFoundException
+    {
+        try
+        {
+            return (ConflictResolver) container.lookup( ConflictResolver.ROLE, type );
+        }
+        catch ( ComponentLookupException exception )
+        {
+            throw new ConflictResolverNotFoundException( "Cannot find conflict resolver of type: " + type );
+        }
+    }
+
+    // Contextualizable methods -----------------------------------------------
+
+    /*
+     * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
+     */
+    public void contextualize( Context context ) throws ContextException
+    {
+        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolverFactory.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/branches/MNG-612/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/MNG-612/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml Thu Jun 28 09:26:15 2007
@@ -190,6 +190,17 @@
       <role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
       <implementation>org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory</implementation>
     </component>
+    
+    <!--
+     |
+     | ConflictResolverFactory
+     |
+     -->
+    <component>
+      <role>org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory</role>
+      <implementation>org.apache.maven.artifact.resolver.conflict.DefaultConflictResolverFactory</implementation>
+    </component>
+    
   </components>
 
 </component-set>

Modified: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.java Thu Jun 28 09:26:15 2007
@@ -37,13 +37,31 @@
  */
 public interface ArtifactCollector
 {
+    /**
+     * The plexus role for this component.
+     * 
+     * @since 2.0.8
+     */
+    String ROLE = ArtifactCollector.class.getName();
+
+    // TODO: deprecate since conflict resolvers should always be specified
     ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository,
                                       List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter,
                                       List listeners )
         throws ArtifactResolutionException;
 
+    // TODO: deprecate since conflict resolvers should always be specified
     ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
                                       ArtifactRepository localRepository, List remoteRepositories,
                                       ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
+        throws ArtifactResolutionException;
+
+    /**
+     * @since 2.0.8
+     */
+    ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
+                                      ArtifactRepository localRepository, List remoteRepositories,
+                                      ArtifactMetadataSource source, ArtifactFilter filter, List listeners,
+                                      List conflictResolvers )
         throws ArtifactResolutionException;
 }

Modified: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java Thu Jun 28 09:26:15 2007
@@ -93,6 +93,20 @@
                                                   List listeners )
         throws ArtifactResolutionException, ArtifactNotFoundException;
 
+    /**
+     * @since 2.0.8
+     */
+    ArtifactResolutionResult resolveTransitively( Set artifacts,
+                                                  Artifact originatingArtifact,
+                                                  Map managedVersions,
+                                                  ArtifactRepository localRepository,
+                                                  List remoteRepositories,
+                                                  ArtifactMetadataSource source,
+                                                  ArtifactFilter filter,
+                                                  List listeners,
+                                                  List conflictResolvers )
+        throws ArtifactResolutionException, ArtifactNotFoundException;
+
     void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
         throws ArtifactResolutionException, ArtifactNotFoundException;
 }

Modified: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java Thu Jun 28 09:26:15 2007
@@ -24,6 +24,7 @@
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.metadata.ResolutionGroup;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolver;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
@@ -49,6 +50,11 @@
 public class DefaultArtifactCollector
     implements ArtifactCollector
 {
+    /**
+     * The conflict resolver to use when none is specified.
+     */
+    private ConflictResolver defaultConflictResolver;
+    
     public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact,
                                              ArtifactRepository localRepository, List remoteRepositories,
                                              ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
@@ -63,6 +69,23 @@
                                              ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
         throws ArtifactResolutionException
     {
+        return collect( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories,
+                        source, filter, listeners, null );
+    }
+
+    public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
+                                             ArtifactRepository localRepository, List remoteRepositories,
+                                             ArtifactMetadataSource source, ArtifactFilter filter, List listeners,
+                                             List conflictResolvers )
+        throws ArtifactResolutionException
+    {
+        if ( conflictResolvers == null )
+        {
+            // TODO: warn that we're using the default conflict resolver
+            
+            conflictResolvers = Collections.singletonList( defaultConflictResolver );
+        }
+        
         Map resolvedArtifacts = new HashMap();
 
         ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories );
@@ -72,7 +95,7 @@
         ManagedVersionMap versionMap = getManagedVersionsMap( originatingArtifact, managedVersions );
 
         recurse( root, resolvedArtifacts, versionMap, localRepository, remoteRepositories, source, filter,
-                 listeners );
+                 listeners, conflictResolvers );
 
         Set set = new HashSet();
 
@@ -142,7 +165,7 @@
 
     private void recurse( ResolutionNode node, Map resolvedArtifacts, ManagedVersionMap managedVersions,
                           ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source,
-                          ArtifactFilter filter, List listeners )
+                          ArtifactFilter filter, List listeners, List conflictResolvers )
         throws CyclicDependencyException, ArtifactResolutionException, OverConstrainedVersionException
     {
         fireEvent( ResolutionListener.TEST_ARTIFACT, listeners, node );
@@ -202,13 +225,34 @@
                     }
 
                     // Conflict Resolution
-                    // TODO: use as conflict resolver(s), chain
+                    ResolutionNode resolved = null;
+                    for ( Iterator j = conflictResolvers.iterator(); resolved == null && j.hasNext(); )
+                    {
+                        ConflictResolver conflictResolver = (ConflictResolver) j.next();
+
+                        resolved = conflictResolver.resolveConflict( previous, node );
+                    }
+
+                    if ( resolved == null )
+                    {
+                        // TODO: throw better exception that can detail the two conflicting artifacts
+                        throw new ArtifactResolutionException( "Cannot resolve artifact version conflict between "
+                                        + previous.getArtifact().getVersion() + " and "
+                                        + node.getArtifact().getVersion(), previous.getArtifact() );
+                    }
+                    
+                    if ( resolved != previous && resolved != node )
+                    {
+                        // TODO: throw better exception
+                        throw new ArtifactResolutionException( "Conflict resolver returned unknown resolution node: ",
+                                                               resolved.getArtifact() );
+                    }
 
                     // TODO: should this be part of mediation?
                     // previous one is more dominant
                     ResolutionNode nearest;
                     ResolutionNode farthest;
-                    if ( previous.getDepth() <= node.getDepth() )
+                    if ( resolved == previous )
                     {
                         nearest = previous;
                         farthest = node;
@@ -366,7 +410,7 @@
                     }
 
                     recurse( child, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source,
-                             filter, listeners );
+                             filter, listeners, conflictResolvers );
                 }
             }
 

Modified: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.java Thu Jun 28 09:26:15 2007
@@ -19,11 +19,29 @@
  * under the License.
  */
 
+import org.apache.maven.artifact.resolver.ResolutionNode;
+
 /**
+ * Determines which version of an artifact to use when there are conflicting declarations.
+ * 
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
  * @version $Id$
  */
 public interface ConflictResolver
 {
     static String ROLE = ConflictResolver.class.getName();
+
+    /**
+     * Determines which of the specified versions of an artifact to use when there are conflicting declarations.
+     * 
+     * @param node1
+     *            the first artifact declaration
+     * @param node2
+     *            the second artifact declaration
+     * @return the artifact declaration to use: <code>node1</code>; <code>node2</code>; or <code>null</code>if
+     *         this conflict cannot be resolved
+     * @since 2.0.8
+     */
+    ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 );
 }

Added: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,51 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A factory that produces conflict resolvers of various types.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @since 2.0.8
+ * @see ConflictResolver
+ */
+public interface ConflictResolverFactory
+{
+    // constants --------------------------------------------------------------
+    
+    /**
+     * The plexus role for this component.
+     */
+    String ROLE = ConflictResolverFactory.class.getName();
+    
+    // methods ----------------------------------------------------------------
+    
+    /**
+     * Gets a conflict resolver of the specified type.
+     * 
+     * @param type
+     *            the type of conflict resolver to obtain
+     * @return the conflict resolver
+     * @throws ConflictResolverNotFoundException
+     *             if the specified type was not found
+     */
+    ConflictResolver getConflictResolver( String type ) throws ConflictResolverNotFoundException;
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverFactory.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,50 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Indicates that a specified conflict resolver implementation could not be found.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @since 2.0.8
+ */
+public class ConflictResolverNotFoundException extends Exception
+{
+    // constants --------------------------------------------------------------
+
+    /**
+     * The serial version ID.
+     */
+    private static final long serialVersionUID = 3372412184339653914L;
+
+    // constructors -----------------------------------------------------------
+
+    /**
+     * Creates a new <code>ConflictResolverNotFoundException</code> with the specified message.
+     * 
+     * @param message
+     *            the message
+     */
+    public ConflictResolverNotFoundException( String message )
+    {
+        super( message );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolverNotFoundException.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.java Thu Jun 28 09:26:15 2007
@@ -20,10 +20,14 @@
  */
 
 /**
+ * The default conflict resolver that delegates to the nearest strategy.
+ * 
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
+ * @see NearestConflictResolver
+ * @deprecated As of 2.0.8, use a specific implementation instead, e.g. {@link NearestConflictResolver}
  */
 public class DefaultConflictResolver
-    implements ConflictResolver
+    extends NearestConflictResolver
 {
 }

Added: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,44 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+
+/**
+ * Resolves conflicting artifacts by always selecting the <em>farthest</em> declaration. Farthest is defined as the
+ * declaration that has the most transitive steps away from the project being built.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public class FarthestConflictResolver
+    implements ConflictResolver
+{
+    // ConflictResolver methods -----------------------------------------------
+    
+    /*
+     * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode,
+     *      org.apache.maven.artifact.resolver.ResolutionNode)
+     */
+    public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 )
+    {
+        return node1.getDepth() >= node2.getDepth() ? node1 : node2;
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolver.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,45 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+
+/**
+ * Resolves conflicting artifacts by always selecting the <em>nearest</em> declaration. Nearest is defined as the
+ * declaration that has the least transitive steps away from the project being built.
+ * 
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public class NearestConflictResolver
+    implements ConflictResolver
+{
+    // ConflictResolver methods -----------------------------------------------
+    
+    /*
+     * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode,
+     *      org.apache.maven.artifact.resolver.ResolutionNode)
+     */
+    public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 )
+    {
+        return node1.getDepth() <= node2.getDepth() ? node1 : node2;
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolver.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,59 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
+
+/**
+ * Resolves conflicting artifacts by always selecting the <em>newest</em> declaration. Newest is defined as the
+ * declaration whose version is greater according to <code>ArtifactVersion.compareTo</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ArtifactVersion#compareTo(Object)
+ */
+public class NewestConflictResolver
+    implements ConflictResolver
+{
+    // ConflictResolver methods -----------------------------------------------
+    
+    /*
+     * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode,
+     *      org.apache.maven.artifact.resolver.ResolutionNode)
+     */
+    public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 )
+    {
+        try
+        {
+            ArtifactVersion version1 = node1.getArtifact().getSelectedVersion();
+            ArtifactVersion version2 = node2.getArtifact().getSelectedVersion();
+            
+            return version1.compareTo( version2 ) > 0 ? node1 : node2;
+        }
+        catch (OverConstrainedVersionException exception)
+        {
+            // TODO: log message or throw exception?
+            
+            return null;
+        }
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolver.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,59 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
+
+/**
+ * Resolves conflicting artifacts by always selecting the <em>oldest</em> declaration. Oldest is defined as the
+ * declaration whose version is less according to <code>ArtifactVersion.compareTo</code>.
+ * 
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see ArtifactVersion#compareTo(Object)
+ */
+public class OldestConflictResolver
+    implements ConflictResolver
+{
+    // ConflictResolver methods -----------------------------------------------
+    
+    /*
+     * @see org.apache.maven.artifact.resolver.conflict.ConflictResolver#resolveConflict(org.apache.maven.artifact.resolver.ResolutionNode,
+     *      org.apache.maven.artifact.resolver.ResolutionNode)
+     */
+    public ResolutionNode resolveConflict( ResolutionNode node1, ResolutionNode node2 )
+    {
+        try
+        {
+            ArtifactVersion version1 = node1.getArtifact().getSelectedVersion();
+            ArtifactVersion version2 = node2.getArtifact().getSelectedVersion();
+            
+            return version1.compareTo( version2 ) <= 0 ? node1 : node2;
+        }
+        catch (OverConstrainedVersionException exception)
+        {
+            // TODO: log message or throw exception?
+            
+            return null;
+        }
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolver.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/branches/MNG-612/maven-artifact/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/main/resources/META-INF/plexus/components.xml Thu Jun 28 09:26:15 2007
@@ -204,6 +204,41 @@
     <component>
       <role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
       <implementation>org.apache.maven.artifact.resolver.DefaultArtifactCollector</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.artifact.resolver.conflict.ConflictResolver</role>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.resolver.conflict.ConflictResolver</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.artifact.resolver.conflict.NearestConflictResolver</implementation>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.resolver.conflict.ConflictResolver</role>
+      <role-hint>nearest</role-hint>
+      <implementation>org.apache.maven.artifact.resolver.conflict.NearestConflictResolver</implementation>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.resolver.conflict.ConflictResolver</role>
+      <role-hint>farthest</role-hint>
+      <implementation>org.apache.maven.artifact.resolver.conflict.FarthestConflictResolver</implementation>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.resolver.conflict.ConflictResolver</role>
+      <role-hint>newest</role-hint>
+      <implementation>org.apache.maven.artifact.resolver.conflict.NewestConflictResolver</implementation>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.resolver.conflict.ConflictResolver</role>
+      <role-hint>oldest</role-hint>
+      <implementation>org.apache.maven.artifact.resolver.conflict.OldestConflictResolver</implementation>
     </component>
   </components>
 </component-set>

Modified: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java (original)
+++ maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java Thu Jun 28 09:26:15 2007
@@ -70,7 +70,7 @@
 
         this.source = new Source();
         this.artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-        this.artifactCollector = new DefaultArtifactCollector();
+        this.artifactCollector = (ArtifactCollector) lookup( ArtifactCollector.ROLE );
 
         this.projectArtifact = createArtifact( "project", "1.0", null );
     }

Added: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,143 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Provides a basis for testing conflict resolvers.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ */
+public abstract class AbstractConflictResolverTest
+    extends PlexusTestCase
+{
+    // constants --------------------------------------------------------------
+    
+    private static final String GROUP_ID = "test";
+    
+    // fields -----------------------------------------------------------------
+    
+    protected Artifact a1;
+
+    protected Artifact a2;
+
+    protected Artifact b1;
+
+    private final String roleHint;
+    
+    private ArtifactFactory artifactFactory;
+
+    private ConflictResolver conflictResolver;
+    
+    // constructors -----------------------------------------------------------
+    
+    public AbstractConflictResolverTest( String roleHint )
+        throws Exception
+    {
+        this.roleHint = roleHint;
+    }
+    
+    // TestCase methods -------------------------------------------------------
+    
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+        conflictResolver = (ConflictResolver) lookup( ConflictResolver.ROLE, roleHint );
+        
+        a1 = createArtifact( "a", "1.0" );
+        a2 = createArtifact( "a", "2.0" );
+        b1 = createArtifact( "b", "1.0" );
+    }
+    
+    /*
+     * @see org.codehaus.plexus.PlexusTestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        a1 = null;
+        a2 = null;
+        b1 = null;
+        
+        artifactFactory = null;
+        conflictResolver = null;
+        
+        super.tearDown();
+    }
+    
+    // protected methods ------------------------------------------------------
+    
+    protected ConflictResolver getConflictResolver()
+    {
+        return conflictResolver;
+    }
+    
+    protected void assertResolveConflict( ResolutionNode expectedNode, ResolutionNode actualNode1, ResolutionNode actualNode2 )
+    {
+        ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 );
+        
+        assertNotNull( "Expected resolvable", resolvedNode );
+        assertEquals( "Resolution node", expectedNode, resolvedNode );
+    }
+
+    protected void assertUnresolvableConflict( ResolutionNode actualNode1, ResolutionNode actualNode2 )
+    {
+        ResolutionNode resolvedNode = getConflictResolver().resolveConflict( actualNode1, actualNode2 );
+        
+        assertNull( "Expected unresolvable", resolvedNode );
+    }
+
+    protected Artifact createArtifact( String id, String version ) throws InvalidVersionSpecificationException
+    {
+        return createArtifact( id, version, Artifact.SCOPE_COMPILE );
+    }
+
+    protected Artifact createArtifact( String id, String version, boolean optional )
+        throws InvalidVersionSpecificationException
+    {
+        return createArtifact( id, version, Artifact.SCOPE_COMPILE, null, optional );
+    }
+
+    protected Artifact createArtifact( String id, String version, String scope )
+        throws InvalidVersionSpecificationException
+    {
+        return createArtifact( id, version, scope, null, false );
+    }
+
+    protected Artifact createArtifact( String id, String version, String scope, String inheritedScope, boolean optional )
+        throws InvalidVersionSpecificationException
+    {
+        VersionRange versionRange = VersionRange.createFromVersionSpec( version );
+        
+        return artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope,
+                                                         inheritedScope, optional );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/AbstractConflictResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,120 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+
+/**
+ * Tests <code>FarthestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see FarthestConflictResolver
+ */
+public class FarthestConflictResolverTest
+    extends AbstractConflictResolverTest
+{
+    // constructors -----------------------------------------------------------
+    
+    public FarthestConflictResolverTest()
+        throws Exception
+    {
+        super("farthest");
+    }
+    
+    // tests ------------------------------------------------------------------
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * b:1.0 -> a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepth()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        
+        assertResolveConflict( a2n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * b:1.0 -> a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepthReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a2n, a2n, a1n );
+    }
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqual()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a1n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqualReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a2n, a2n, a1n );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/FarthestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,120 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+
+/**
+ * Tests <code>NearestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see NearestConflictResolver
+ */
+public class NearestConflictResolverTest
+    extends AbstractConflictResolverTest
+{
+    // constructors -----------------------------------------------------------
+    
+    public NearestConflictResolverTest()
+        throws Exception
+    {
+        super("nearest");
+    }
+    
+    // tests ------------------------------------------------------------------
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * b:1.0 -> a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepth()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        
+        assertResolveConflict( a1n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * b:1.0 -> a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepthReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a1n, a2n, a1n );
+    }
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqual()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a1n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqualReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a2n, a2n, a1n );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NearestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,120 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+
+/**
+ * Tests <code>NewestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see NewestConflictResolver
+ */
+public class NewestConflictResolverTest
+    extends AbstractConflictResolverTest
+{
+    // constructors -----------------------------------------------------------
+    
+    public NewestConflictResolverTest()
+        throws Exception
+    {
+        super("newest");
+    }
+    
+    // tests ------------------------------------------------------------------
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * b:1.0 -> a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepth()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        
+        assertResolveConflict( a2n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * b:1.0 -> a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepthReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a2n, a2n, a1n );
+    }
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqual()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a2n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:2.0</code> wins in the scenario:
+     * <pre>
+     * a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqualReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a2n, a2n, a1n );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/NewestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java?view=auto&rev=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java (added)
+++ maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java Thu Jun 28 09:26:15 2007
@@ -0,0 +1,120 @@
+package org.apache.maven.artifact.resolver.conflict;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+
+import org.apache.maven.artifact.resolver.ResolutionNode;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+
+/**
+ * Tests <code>OldestConflictResolver</code>.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @see OldestConflictResolver
+ */
+public class OldestConflictResolverTest
+    extends AbstractConflictResolverTest
+{
+    // constructors -----------------------------------------------------------
+    
+    public OldestConflictResolverTest()
+        throws Exception
+    {
+        super("oldest");
+    }
+    
+    // tests ------------------------------------------------------------------
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * b:1.0 -> a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepth()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        
+        assertResolveConflict( a1n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * b:1.0 -> a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testDepthReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a1n, a2n, a1n );
+    }
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * a:1.0
+     * a:2.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqual()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a1n, a1n, a2n );
+    }
+
+    /**
+     * Tests that <code>a:1.0</code> wins in the scenario:
+     * <pre>
+     * a:2.0
+     * a:1.0
+     * </pre>
+     *
+     * @throws InvalidVersionSpecificationException
+     */
+    public void testEqualReversed()
+        throws InvalidVersionSpecificationException
+    {
+        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
+        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
+        
+        assertResolveConflict( a1n, a2n, a1n );
+    }
+}

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-612/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/conflict/OldestConflictResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java (original)
+++ maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java Thu Jun 28 09:26:15 2007
@@ -32,10 +32,13 @@
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolverNotFoundException;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.model.Extension;
 import org.apache.maven.plugin.DefaultPluginManager;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectUtils;
 import org.apache.maven.wagon.Wagon;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
@@ -77,6 +80,8 @@
     private ArtifactFilter artifactFilter = MavenArtifactFilterManager.createStandardFilter();
 
     private WagonManager wagonManager;
+    
+    private ConflictResolverFactory conflictResolverFactory;
 
     private static final String CONTAINER_NAME = "extensions";
 
@@ -118,12 +123,26 @@
             // Make sure that we do not influence the dependenecy resolution of extensions with the project's
             // dependencyManagement
 
+            List conflictResolvers = null;
+            try
+            {
+                conflictResolvers = ProjectUtils.buildConflictResolvers( project, conflictResolverFactory );
+                
+                getLogger().debug( "Using conflict resolvers: " + conflictResolvers );
+            }
+            catch ( ConflictResolverNotFoundException exception )
+            {
+                // TODO: propagate exception when possible
+                getLogger().warn( "Cannot build conflict resolvers, using default", exception );
+            }
+            
             ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, project.getArtifact(),
                                                                                     Collections.EMPTY_MAP,
                                                                                     //project.getManagedVersionMap(),
                                                                                     localRepository,
                                                                                     project.getRemoteArtifactRepositories(),
-                                                                                    artifactMetadataSource, filter );
+                                                                                    artifactMetadataSource, filter, null,
+                                                                                    conflictResolvers );
             // create a child container for the extension
             // TODO: this could surely be simpler/different on trunk with the new classworlds
 

Modified: maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/branches/MNG-612/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Thu Jun 28 09:26:15 2007
@@ -30,6 +30,8 @@
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolverNotFoundException;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
@@ -53,6 +55,7 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectUtils;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.project.path.PathTranslator;
@@ -123,6 +126,8 @@
     protected MavenProjectBuilder mavenProjectBuilder;
 
     protected PluginMappingManager pluginMappingManager;
+    
+    private ConflictResolverFactory conflictResolverFactory;
 
     // END component requirements
 
@@ -651,11 +656,25 @@
             repositories.addAll( resolutionGroup.getResolutionRepositories() );
             repositories.addAll( project.getRemoteArtifactRepositories() );
 
+            List conflictResolvers = null;
+            try
+            {
+                conflictResolvers = ProjectUtils.buildConflictResolvers( project, conflictResolverFactory );
+                
+                getLogger().debug( "Using conflict resolvers: " + conflictResolvers );
+            }
+            catch ( ConflictResolverNotFoundException exception )
+            {
+                // TODO: propagate exception when possible
+                getLogger().warn( "Cannot build conflict resolvers, using default", exception );
+            }
+            
             ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact,
                                                                                     Collections.EMPTY_MAP,
                                                                                     localRepository, repositories,
                                                                                     artifactMetadataSource,
-                                                                                    artifactFilter );
+                                                                                    artifactFilter, null,
+                                                                                    conflictResolvers );
 
             Set resolved = result.getArtifacts();
 
@@ -1235,12 +1254,27 @@
         {
             project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
         }
+        
+        List conflictResolvers = null;
+        try
+        {
+            conflictResolvers = ProjectUtils.buildConflictResolvers( project, conflictResolverFactory );
+            
+            getLogger().debug( "Using conflict resolvers: " + conflictResolvers );
+        }
+        catch ( ConflictResolverNotFoundException exception )
+        {
+            // TODO: propagate exception when possible
+            getLogger().warn( "Cannot build conflict resolvers, using default", exception );
+        }
+        
         ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
                                                                                 artifact,
                                                                                 project.getManagedVersionMap(),
                                                                                 context.getLocalRepository(),
                                                                                 project.getRemoteArtifactRepositories(),
-                                                                                artifactMetadataSource, filter );
+                                                                                artifactMetadataSource, filter, null,
+                                                                                conflictResolvers );
 
         project.setArtifacts( result.getArtifacts() );
     }

Modified: maven/components/branches/MNG-612/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-core/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/MNG-612/maven-core/src/main/resources/META-INF/plexus/components.xml Thu Jun 28 09:26:15 2007
@@ -50,6 +50,9 @@
         <requirement>
           <role>org.apache.maven.project.MavenProjectBuilder</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory</role>
+        </requirement>
       </requirements>
     </component>
 
@@ -68,6 +71,9 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.manager.WagonManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory</role>
         </requirement>
       </requirements>
     </component>

Modified: maven/components/branches/MNG-612/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-612/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?view=diff&rev=551613&r1=551612&r2=551613
==============================================================================
--- maven/components/branches/MNG-612/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/branches/MNG-612/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Thu Jun 28 09:26:15 2007
@@ -33,6 +33,8 @@
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolverNotFoundException;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
@@ -172,6 +174,8 @@
     private ModelInterpolator modelInterpolator;
 
     private ArtifactRepositoryFactory artifactRepositoryFactory;
+    
+    private ConflictResolverFactory conflictResolverFactory;
 
     // ----------------------------------------------------------------------
     // I am making this available for use with a new method that takes a
@@ -364,11 +368,25 @@
             wagonManager.setDownloadMonitor( transferListener );
         }
 
+        List conflictResolvers = null;
+        try
+        {
+            conflictResolvers = ProjectUtils.buildConflictResolvers( project, conflictResolverFactory );
+            
+            getLogger().debug( "Using conflict resolvers: " + conflictResolvers );
+        }
+        catch ( ConflictResolverNotFoundException exception )
+        {
+            // TODO: propagate exception when possible
+            getLogger().warn( "Cannot build conflict resolvers, using default", exception );
+        }
+        
         ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
                                                                                 projectArtifact, managedVersions,
                                                                                 localRepository,
                                                                                 project.getRemoteArtifactRepositories(),
-                                                                                artifactMetadataSource );
+                                                                                artifactMetadataSource, null, null,
+                                                                                conflictResolvers );
 
         project.setArtifacts( result.getArtifacts() );