You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2006/01/24 22:47:11 UTC
svn commit: r372027 -
/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
Author: carlos
Date: Tue Jan 24 13:47:10 2006
New Revision: 372027
URL: http://svn.apache.org/viewcvs?rev=372027&view=rev
Log:
Refactor
PR: MNG-1895
Modified:
maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java?rev=372027&r1=372026&r2=372027&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java Tue Jan 24 13:47:10 2006
@@ -185,26 +185,30 @@
// TODO: should this be part of mediation?
// previous one is more dominant
+ ResolutionNode nearest, farthest;
if ( previous.getDepth() <= node.getDepth() )
{
- checkScopeUpdate( node, previous, listeners );
+ nearest = previous;
+ farthest = node;
}
else
{
- checkScopeUpdate( previous, node, listeners );
+ nearest = node;
+ farthest = previous;
}
- if ( previous.getDepth() <= node.getDepth() )
- {
- // previous was nearer
- fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, node, previous.getArtifact() );
- node.disable();
- }
- else
+ /* if we need to update scope of nearest to use farthest scope */
+ if ( checkScopeUpdate( farthest, nearest, listeners ) )
{
- fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, previous, node.getArtifact() );
- previous.disable();
+ fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthest.getArtifact() );
+
+ // previously we cloned the artifact, but it is more effecient to just update the scope
+ // if problems are later discovered that the original object needs its original scope value, cloning may
+ // again be appropriate
+ nearest.getArtifact().setScope( farthest.getArtifact().getScope() );
}
+ fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, farthest, nearest.getArtifact() );
+ farthest.disable();
}
}
}
@@ -316,13 +320,13 @@
}
/**
- * Check if the scope needs to be updated.
+ * Check if the scope of the nearest needs to be updated with the scope of the farthest.
* <a href="http://docs.codehaus.org/x/IGU#DependencyMediationandConflictResolution-Scoperesolution">More info</a>.
* @param farthest farthest resolution node
* @param nearest nearest resolution node
* @param listeners
*/
- void checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners )
+ private boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners )
{
boolean updateScope = false;
Artifact farthestArtifact = farthest.getArtifact();
@@ -349,15 +353,7 @@
fireEvent( ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners, nearest, farthestArtifact );
}
- if ( updateScope )
- {
- fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact );
-
- // previously we cloned the artifact, but it is more effecient to just update the scope
- // if problems are later discovered that the original object needs its original scope value, cloning may
- // again be appropriate
- nearestArtifact.setScope( farthestArtifact.getScope() );
- }
+ return updateScope;
}
private void fireEvent( int event, List listeners, ResolutionNode node )