You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/02/22 02:55:49 UTC
svn commit: r379648 - in
/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver:
DefaultArtifactCollector.java ResolutionNode.java
Author: brett
Date: Tue Feb 21 17:55:47 2006
New Revision: 379648
URL: http://svn.apache.org/viewcvs?rev=379648&view=rev
Log:
[MNG-1895] correct version handling to make tests pass
Modified:
maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
Modified: maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java?rev=379648&r1=379647&r2=379648&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (original)
+++ maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java Tue Feb 21 17:55:47 2006
@@ -81,7 +81,7 @@
if ( node.filterTrail( filter ) )
{
- // If it was optional and not a direct dependency,
+ // If it was optional and not a direct dependency,
// we don't add it or its children, just allow the update of the version and scope
if ( node.isChildOfRootNode() || !artifact.isOptional() )
{
@@ -137,18 +137,7 @@
VersionRange previousRange = previous.getArtifact().getVersionRange();
VersionRange currentRange = node.getArtifact().getVersionRange();
- // TODO: why do we force the version on it? what if they don't match?
- if ( previousRange == null )
- {
- // version was already resolved
- node.getArtifact().setVersion( previous.getArtifact().getVersion() );
- }
- else if ( currentRange == null )
- {
- // version was already resolved
- previous.getArtifact().setVersion( node.getArtifact().getVersion() );
- }
- else
+ if ( previousRange != null && currentRange != null )
{
// TODO: shouldn't need to double up on this work, only done for simplicity of handling recommended
// version but the restriction is identical
@@ -185,7 +174,8 @@
// TODO: should this be part of mediation?
// previous one is more dominant
- ResolutionNode nearest, farthest;
+ ResolutionNode nearest;
+ ResolutionNode farthest;
if ( previous.getDepth() <= node.getDepth() )
{
nearest = previous;
@@ -197,11 +187,9 @@
farthest = previous;
}
- /* if we need to update scope of nearest to use farthest scope */
if ( checkScopeUpdate( farthest, nearest, listeners ) )
{
- fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthest.getArtifact() );
- /* we need nearest version but farthest scope */
+ // if we need to update scope of nearest to use farthest scope, use the nearest version, but farthest scope
nearest.disable();
farthest.getArtifact().setVersion( nearest.getArtifact().getVersion() );
}
@@ -321,13 +309,14 @@
}
/**
- * Check if the scope of the nearest needs to be updated with the scope of the farthest.
+ * Check if the scope needs to be updated.
* <a href="http://docs.codehaus.org/x/IGU#DependencyMediationandConflictResolution-Scoperesolution">More info</a>.
- * @param farthest farthest resolution node
- * @param nearest nearest resolution node
+ *
+ * @param farthest farthest resolution node
+ * @param nearest nearest resolution node
* @param listeners
*/
- private boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners )
+ boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners )
{
boolean updateScope = false;
Artifact farthestArtifact = farthest.getArtifact();
@@ -363,7 +352,7 @@
// again be appropriate
nearestArtifact.setScope( farthestArtifact.getScope() );
}
-
+
return updateScope;
}
Modified: maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java?rev=379648&r1=379647&r2=379648&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java (original)
+++ maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java Tue Feb 21 17:55:47 2006
@@ -146,7 +146,7 @@
{
return children != null;
}
-
+
public boolean isChildOfRootNode()
{
return parent != null && parent.parent == null;
@@ -219,7 +219,7 @@
public String toString()
{
- return artifact.toString() + " (" + depth + ")";
+ return artifact.toString() + " (" + depth + "; " + ( active ? "enabled" : "disabled" ) + ")";
}
}