You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/10/25 21:22:03 UTC
svn commit: r588317 - in
/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver:
DebugResolutionListener.java DefaultArtifactCollector.java
DefaultArtifactResolver.java ResolutionListener.java
ResolutionListenerForDepMgmt.java
Author: jdcasey
Date: Thu Oct 25 12:22:02 2007
New Revision: 588317
URL: http://svn.apache.org/viewvc?rev=588317&view=rev
Log:
Manage system path if an artifact winds up with system scope. Also, be more careful about system-scoped artifact file paths.
Modified:
maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java
maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener.java
maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java
Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java?rev=588317&r1=588316&r2=588317&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.java Thu Oct 25 12:22:02 2007
@@ -40,7 +40,7 @@
private String indent = "";
private static Set ignoredArtifacts = new HashSet();
-
+
public DebugResolutionListener( Logger logger )
{
this.logger = logger;
@@ -151,6 +151,16 @@
if ( !replacement.getScope().equals( artifact.getScope() ) )
{
String msg = indent + artifact + " (applying scope: " + replacement.getScope() + ")";
+ logger.debug( msg );
+ }
+ }
+
+ public void manageArtifactSystemPath( Artifact artifact, Artifact replacement )
+ {
+ // only show msg if a change is actually taking place
+ if ( !replacement.getScope().equals( artifact.getScope() ) )
+ {
+ String msg = indent + artifact + " (applying system path: " + replacement.getFile() + ")";
logger.debug( msg );
}
}
Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java?rev=588317&r1=588316&r2=588317&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java Thu Oct 25 12:22:02 2007
@@ -57,7 +57,7 @@
* The conflict resolver to use when none is specified.
*/
private ConflictResolver defaultConflictResolver;
-
+
public ArtifactResolutionResult collect( Set artifacts,
Artifact originatingArtifact,
ArtifactRepository localRepository,
@@ -96,7 +96,7 @@
conflictResolvers = Collections.singletonList( defaultConflictResolver );
}
-
+
Map resolvedArtifacts = new LinkedHashMap();
ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories );
@@ -173,7 +173,7 @@
Map managedVersions )
{
ManagedVersionMap versionMap;
- if ( managedVersions != null && managedVersions instanceof ManagedVersionMap )
+ if ( ( managedVersions != null ) && ( managedVersions instanceof ManagedVersionMap ) )
{
versionMap = (ManagedVersionMap) managedVersions;
}
@@ -240,7 +240,7 @@
VersionRange previousRange = previous.getArtifact().getVersionRange();
VersionRange currentRange = node.getArtifact().getVersionRange();
- if ( previousRange != null && currentRange != null )
+ 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
@@ -261,8 +261,8 @@
for ( int j = 0; j < 2; j++ )
{
Artifact resetArtifact = resetNodes[j].getArtifact();
- if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null &&
- resetArtifact.getAvailableVersions() != null )
+ if ( ( resetArtifact.getVersion() == null ) && ( resetArtifact.getVersionRange() != null ) &&
+ ( resetArtifact.getAvailableVersions() != null ) )
{
resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion(
@@ -274,7 +274,7 @@
// Conflict Resolution
ResolutionNode resolved = null;
- for ( Iterator j = conflictResolvers.iterator(); resolved == null && j.hasNext(); )
+ for ( Iterator j = conflictResolvers.iterator(); ( resolved == null ) && j.hasNext(); )
{
ConflictResolver conflictResolver = (ConflictResolver) j.next();
@@ -290,14 +290,14 @@
+ node.getArtifact().getVersion(), previous.getArtifact() ) );
}
- if ( resolved != previous && resolved != node )
+ if ( ( resolved != previous ) && ( resolved != node ) )
{
// TODO: add better exception
result.addVersionRangeViolation( new ArtifactResolutionException(
"Conflict resolver returned unknown resolution node: ",
resolved.getArtifact() ) );
}
-
+
// TODO: should this be part of mediation?
// previous one is more dominant
@@ -506,19 +506,26 @@
// provide defaults to children, but should override transitives).
// We can do this by calling isChildOfRootNode on the current node.
- if ( artifact.getVersion() != null
+ if ( ( artifact.getVersion() != null )
&& ( node.isChildOfRootNode() ? node.getArtifact().getVersion() == null : true ) )
{
fireEvent( ResolutionListener.MANAGE_ARTIFACT_VERSION, listeners, node, artifact );
node.getArtifact().setVersion( artifact.getVersion() );
}
- if ( artifact.getScope() != null
+ if ( ( artifact.getScope() != null )
&& ( node.isChildOfRootNode() ? node.getArtifact().getScope() == null : true ) )
{
fireEvent( ResolutionListener.MANAGE_ARTIFACT_SCOPE, listeners, node, artifact );
node.getArtifact().setScope( artifact.getScope() );
}
+
+ if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() )
+ && ( node.getArtifact().getFile() == null ) && ( artifact.getFile() != null ) )
+ {
+ fireEvent( ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH, listeners, node, artifact );
+ node.getArtifact().setFile( artifact.getFile() );
+ }
}
/**
@@ -553,7 +560,7 @@
}
/* current POM rules all, if nearest is in current pom, do not update its scope */
- if ( nearest.getDepth() < 2 && updateScope )
+ if ( ( nearest.getDepth() < 2 ) && updateScope )
{
updateScope = false;
@@ -640,6 +647,17 @@
{
ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener;
asImpl.manageArtifactScope( node.getArtifact(), replacement );
+ }
+ else
+ {
+ listener.manageArtifact( node.getArtifact(), replacement );
+ }
+ break;
+ case ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH:
+ if ( listener instanceof ResolutionListenerForDepMgmt )
+ {
+ ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener;
+ asImpl.manageArtifactSystemPath( node.getArtifact(), replacement );
}
else
{
Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=588317&r1=588316&r2=588317&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java Thu Oct 25 12:22:02 2007
@@ -42,7 +42,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -107,7 +106,11 @@
{
File systemFile = artifact.getFile();
- if ( !systemFile.exists() )
+ if ( systemFile == null )
+ {
+ throw new ArtifactResolutionException( "systemPath not set for system-scoped artifact: " + artifact.getId(), artifact );
+ }
+ else if ( !systemFile.exists() )
{
throw new ArtifactNotFoundException(
"System artifact: " + artifact + " not found in path: " + systemFile,
@@ -377,7 +380,7 @@
return resolveTransitively(
artifacts,
originatingArtifact,
-
+
Collections.EMPTY_MAP,
localRepository,
remoteRepositories,
@@ -399,7 +402,7 @@
return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
remoteRepositories, source, filter, listeners, null );
}
-
+
public ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
Map managedVersions,
Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener.java?rev=588317&r1=588316&r2=588317&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener.java Thu Oct 25 12:22:02 2007
@@ -60,11 +60,13 @@
int SELECT_VERSION_FROM_RANGE = 10;
int RESTRICT_RANGE = 11;
-
+
int MANAGE_ARTIFACT_VERSION = 12;
-
+
int MANAGE_ARTIFACT_SCOPE = 13;
+ int MANAGE_ARTIFACT_SYSTEM_PATH = 14;
+
void testArtifact( Artifact node );
void startProcessChildren( Artifact artifact );
@@ -81,12 +83,12 @@
* @deprecated
*/
void manageArtifact( Artifact artifact, Artifact replacement );
-
+
// TODO Use the following two instead of manageArtifact
// TODO Remove ResolutionListenerDM interface
//void manageArtifactVersion( Artifact artifact, Artifact replacement );
-
+
//void manageArtifactScope( Artifact artifact, Artifact replacement );
void omitForCycle( Artifact artifact );
@@ -94,7 +96,7 @@
/**
* This event means that the scope has NOT been updated to a farther node scope because current
* node is in the first level pom
- *
+ *
* @param artifact current node artifact, the one in the first level pom
* @param ignoredScope scope that was ignored because artifact was in first level pom
*/
Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java?rev=588317&r1=588316&r2=588317&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.java Thu Oct 25 12:22:02 2007
@@ -23,17 +23,19 @@
/**
* Do not use!
- *
+ *
* Should only be implmemented by DebugResolutionListener. Remove this
* when the ResolutionListener interface deprecation of the manageArtifact
* method (and the [yet to be done] addition of these methods to that
* interface) has had a chance to propagate to all interested plugins.
- *
- * @deprecated
+ *
+ * @deprecated
*/
public interface ResolutionListenerForDepMgmt
{
void manageArtifactVersion( Artifact artifact, Artifact replacement );
-
+
void manageArtifactScope( Artifact artifact, Artifact replacement );
+
+ void manageArtifactSystemPath( Artifact artifact, Artifact replacement );
}