- fix ant tasks

- disable cycle detection (warn instead)
- show version in dep trail

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@192966 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-06-22 18:08:21 +00:00
parent 9618d2b856
commit f2653b0cb7
12 changed files with 99 additions and 57 deletions

View File

@ -18,16 +18,12 @@
-->
<target name="initTaskDefs">
<!-- don't forget to set the value! -->
<property name="maven.artifact-ant.lib.dir" value="${user.home}/work/opensource/m2/maven-artifact-ant/target/"/>
<path id="maven.classpath">
<pathelement location="${maven.artifact-ant.lib.dir}/maven-artifact-ant-2.0-SNAPSHOT-dep.jar"/>
<pathelement location="${maven.artifact-ant.lib.dir}maven-artifact-ant-2.0-SNAPSHOT.jar"/>
<!-- don't forget to set the value! -->
<pathelement location="target/maven-artifact-ant-2.0-SNAPSHOT-dep.jar"/>
</path>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
<classpath refid="maven.classpath"/>
</typedef>
</target>

View File

@ -19,8 +19,6 @@
<scope>runtime</scope>
<excludes>
<exclude>ant:ant</exclude>
<!-- Temporary until exclusion back in POM -->
<exclude>junit:junit</exclude>
</excludes>
</dependencySet>
</dependencySets>

View File

@ -46,6 +46,9 @@
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
</requirement>
</requirements>
</component>
@ -181,6 +184,11 @@
</configuration>
</component>
<component>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
<implementation>org.apache.maven.artifact.resolver.DefaultArtifactCollector</implementation>
</component>
<!--
|
|
@ -492,6 +500,5 @@
<role-hint>update</role-hint>
<implementation>org.apache.maven.scm.provider.svn.command.update.SvnUpdateCommand</implementation>
</component>
</components>
</component-set>

View File

@ -7,7 +7,7 @@
</parent>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-SNAPSHOT</version>
<name>MAven Artifact Manager</name>
<name>Maven Artifact Manager</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>

View File

@ -434,7 +434,7 @@ public class DefaultWagonManager
private void handleChecksumFailure( ArtifactRepository repository, String message, Throwable cause )
throws ChecksumFailedException
{
if ( ArtifactRepository.CHECKSUM_POLICY_FAIL.equals( repository.getChecksumPolicy() ) )
if ( repository.failOnChecksumMismatch() )
{
throw new ChecksumFailedException( message, cause );
}

View File

@ -56,7 +56,7 @@ public class DefaultArtifactRepositoryFactory
if ( csumPolicy == null )
{
csumPolicy = ArtifactRepository.CHECKSUM_POLICY_FAIL;
csumPolicy = ArtifactRepository.CHECKSUM_POLICY_WARN;
}
repo = new DefaultArtifactRepository( id, url, repositoryLayout, snapPolicy, csumPolicy );

View File

@ -61,6 +61,11 @@ public class DebugResolutionListener
logger.debug( indent + omitted.getId() + " (removed - nearer found: " + kept.getVersion() + ")" );
}
public void omitForCycle( Artifact omitted )
{
logger.debug( indent + omitted.getId() + " (removed - causes a cycle in the graph)" );
}
public void updateScope( Artifact artifact, String scope )
{
logger.debug( indent + artifact.getId() + " (settings scope to: " + scope + ")" );

View File

@ -58,4 +58,6 @@ public interface ArtifactRepository
String getId();
String getChecksumPolicy();
boolean failOnChecksumMismatch();
}

View File

@ -27,8 +27,16 @@ import org.apache.maven.artifact.Artifact;
public class CyclicDependencyException
extends ArtifactResolutionException
{
private Artifact artifact;
public CyclicDependencyException( String message, Artifact artifact )
{
super( message, artifact );
this.artifact = artifact;
}
public Artifact getArtifact()
{
return artifact;
}
}

View File

@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -150,6 +151,13 @@ public class DefaultArtifactCollector
Set artifacts = source.retrieve( child.getArtifact(), localRepository, remoteRepositories );
child.addDependencies( artifacts, filter );
}
catch ( CyclicDependencyException e )
{
// would like to throw this, but we have crappy stuff in the repo
// no logger to use here either just now
fireEvent( ResolutionListener.OMIT_FOR_CYCLE, listeners,
new ResolutionNode( e.getArtifact(), child ) );
}
catch ( ArtifactMetadataRetrievalException e )
{
child.getArtifact().setDependencyTrail( node.getDependencyTrail() );
@ -226,6 +234,9 @@ public class DefaultArtifactCollector
case ResolutionListener.OMIT_FOR_NEARER:
listener.omitForNearer( node.getArtifact(), replacement );
break;
case ResolutionListener.OMIT_FOR_CYCLE:
listener.omitForCycle( node.getArtifact() );
break;
case ResolutionListener.UPDATE_SCOPE:
listener.updateScope( node.getArtifact(), replacement.getScope() );
break;
@ -248,11 +259,14 @@ public class DefaultArtifactCollector
private final int depth;
private final ResolutionNode parent;
public ResolutionNode( Artifact artifact )
{
this.artifact = artifact;
this.depth = 0;
this.parents = Collections.EMPTY_LIST;
this.parent = null;
}
public ResolutionNode( Artifact artifact, ResolutionNode parent )
@ -262,6 +276,7 @@ public class DefaultArtifactCollector
this.parents = new ArrayList();
this.parents.addAll( parent.parents );
this.parents.add( parent.getKey() );
this.parent = parent;
}
public Artifact getArtifact()
@ -289,7 +304,7 @@ public class DefaultArtifactCollector
{
a.setDependencyTrail( getDependencyTrail() );
throw new CyclicDependencyException( "The dependency is present in a cycle", a );
throw new CyclicDependencyException( "A dependency has introduced a cycle", a );
}
children.add( new ResolutionNode( a, this ) );
@ -299,8 +314,13 @@ public class DefaultArtifactCollector
public List getDependencyTrail()
{
List path = new ArrayList( parents );
path.add( artifact.getId() );
List path = new LinkedList();
ResolutionNode node = this;
while ( node != null )
{
path.add( 0, node.getArtifact().getId() );
node = node.parent;
}
return path;
}

View File

@ -42,6 +42,8 @@ public interface ResolutionListener
int MANAGE_ARTIFACT = 7;
int OMIT_FOR_CYCLE = 8;
void testArtifact( Artifact node );
void startProcessChildren( Artifact artifact );
@ -55,4 +57,6 @@ public interface ResolutionListener
void updateScope( Artifact artifact, String scope );
void manageArtifact( Artifact artifact, Artifact replacement );
void omitForCycle( Artifact artifact );
}

View File

@ -65,7 +65,8 @@ public class DefaultArtifactCollectorTest
this.projectArtifact = createArtifact( "project", "1.0", null );
}
public void testCircularDependencyNotIncludingCurrentProject()
// works, but we don't fail on cycles presently
public void disabledtestCircularDependencyNotIncludingCurrentProject()
throws ArtifactResolutionException
{
ArtifactSpec a = createArtifact( "a", "1.0" );
@ -82,7 +83,8 @@ public class DefaultArtifactCollectorTest
}
}
public void testCircularDependencyIncludingCurrentProject()
// works, but we don't fail on cycles presently
public void disabledtestCircularDependencyIncludingCurrentProject()
throws ArtifactResolutionException
{
ArtifactSpec a = createArtifact( "a", "1.0" );