- 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

@ -1,5 +1,5 @@
<project name="foo" default="foo" xmlns:artifact="urn:maven-artifact-ant">
<!--
<!--
You either need to run the the 'initTaskDefs' task below and
define the artifact namespace like above (choose anything you
like except strings that start with 'antlib:'),
@ -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>
@ -49,22 +45,22 @@
<artifact:dependencies pathId="dependency.classpath" filesetId="dependency.fileset">
<dependency groupId="org.apache.maven.wagon" artifactId="wagon-provider-test" version="1.0-alpha-2">
<exclusion groupId="junit" artifactId="junit" />
<exclusion groupId="junit" artifactId="junit"/>
</dependency>
<dependency groupId="org.codehaus.modello" artifactId="modello-core" version="1.0-alpha-2-SNAPSHOT"/>
<localRepository refid="local.repository"/>
</artifact:dependencies>
<copy todir="target/files">
<fileset refid="dependency.fileset" />
<fileset refid="dependency.fileset"/>
</copy>
<artifact:dependencies filesetId="my.dependency.fileset">
<pom refid="maven.project" />
<pom refid="maven.project"/>
</artifact:dependencies>
<copy todir="target/my-dependencies">
<fileset refid="my.dependency.fileset" />
<fileset refid="my.dependency.fileset"/>
</copy>
<artifact:install file="target/maven-artifact-ant-2.0-SNAPSHOT.jar">
@ -85,21 +81,21 @@
</target>
<target name="test-scm" depends="initTaskDefs">
<mkdir dir="target" />
<mkdir dir="target"/>
<pathconvert targetos="unix" property="repo.path.unix">
<map from="c:" to=""/>
<path>
<pathelement location="${basedir}/target/deployment-repo-scm" />
<pathelement location="${basedir}/target/deployment-repo-scm"/>
</path>
</pathconvert>
<property name="scm.url" value="file://${repo.path.unix}" />
<property name="scm.url" value="file://${repo.path.unix}"/>
<delete dir="${repo.path.unix}" />
<delete dir="${repo.path.unix}"/>
<exec executable="svnadmin" failonerror="true">
<arg line="create ${repo.path.unix}" />
<arg line="create ${repo.path.unix}"/>
</exec>
<artifact:localRepository id="local.repository" location="${basedir}/target/local-repo" layout="default"/>
@ -113,14 +109,14 @@
</artifact:dependencies>
<exec executable="svn" dir="${basedir}/target/local-repo" failonerror="true">
<arg line="import -m 'import' ${scm.url}" />
<arg line="import -m 'import' ${scm.url}"/>
</exec>
<delete dir="${basedir}/target/local-repo-scm" />
<delete dir="${basedir}/target/local-repo-scm"/>
<!-- Could the SCM provider initialise this? -->
<exec executable="svn" dir="${basedir}/target" failonerror="true">
<arg line="co ${scm.url} -N local-repo-scm" />
<arg line="co ${scm.url} -N local-repo-scm"/>
</exec>
<artifact:localRepository id="local.repository.scm" location="${basedir}/target/local-repo-scm" layout="default"/>
@ -134,7 +130,7 @@
<artifact:deploy file="target/maven-artifact-ant-2.0-SNAPSHOT.jar">
<localRepository refid="local.repository.scm"/>
<remoteRepository refid="deploy.repository" />
<remoteRepository refid="deploy.repository"/>
<pom refid="maven.project"/>
</artifact:deploy>
</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

@ -2,7 +2,7 @@
<component-set>
<components>
<!--
<!--
|
| WagonManager
|
@ -12,7 +12,7 @@
<implementation>org.apache.maven.artifact.ant.CustomWagonManager</implementation>
</component>
<!--
<!--
|
| Transformations
|
@ -27,7 +27,7 @@
</requirements>
</component>
<!--
<!--
|
| Resolver
|
@ -46,10 +46,13 @@
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
</requirement>
</requirements>
</component>
<!--
<!--
|
| ArtifactInstaller
|
@ -65,7 +68,7 @@
</requirements>
</component>
<!--
<!--
|
| ArtifactDeployer
|
@ -96,7 +99,7 @@
<implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
</component>
<!--
<!--
|
| ArtifactHandlerManager
|
@ -181,7 +184,12 @@
</configuration>
</component>
<!--
<component>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
<implementation>org.apache.maven.artifact.resolver.DefaultArtifactCollector</implementation>
</component>
<!--
|
|
|
@ -190,7 +198,7 @@
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
<implementation>org.apache.maven.project.interpolation.RegexBasedModelInterpolator</implementation>
</component>
<!--
<!--
|
|
|
@ -233,7 +241,7 @@
</requirement>
</requirements>
</component>
<!--
<!--
|
|
|
@ -242,7 +250,7 @@
<role>org.apache.maven.profiles.activation.ProfileActivationCalculator</role>
<implementation>org.apache.maven.profiles.activation.ProfileActivationCalculator</implementation>
</component>
<!--
<!--
|
|
|
@ -252,7 +260,7 @@
<role-hint>always-on</role-hint>
<implementation>org.apache.maven.profiles.activation.AlwaysOnProfileActivator</implementation>
</component>
<!--
<!--
|
|
|
@ -262,7 +270,7 @@
<role-hint>jdk-prefix</role-hint>
<implementation>org.apache.maven.profiles.activation.JdkPrefixProfileActivator</implementation>
</component>
<!--
<!--
|
|
|
@ -272,7 +280,7 @@
<role-hint>system-property</role-hint>
<implementation>org.apache.maven.profiles.activation.SystemPropertyProfileActivator</implementation>
</component>
<!--
<!--
|
|
|
@ -282,7 +290,7 @@
<role-hint>explicit-listing</role-hint>
<implementation>org.apache.maven.profiles.activation.ExplicitListingProfileActivator</implementation>
</component>
<!--
<!--
|
|
|
@ -291,7 +299,7 @@
<role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
<implementation>org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler</implementation>
</component>
<!--
<!--
|
|
|
@ -300,7 +308,7 @@
<role>org.apache.maven.project.validation.ModelValidator</role>
<implementation>org.apache.maven.project.validation.DefaultModelValidator</implementation>
</component>
<!--
<!--
|
|
|
@ -345,7 +353,7 @@
<implementation>org.apache.maven.wagon.providers.scm.ScmWagon</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
<requirements>
<requirement>
<requirement>
<role>org.apache.maven.scm.manager.ScmManager</role>
</requirement>
</requirements>
@ -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

@ -26,7 +26,7 @@ public class DefaultArtifactRepositoryFactory
{
// TODO: use settings?
private String globalSnapshotPolicy = null;
private String globalChecksumPolicy = null;
public ArtifactRepository createArtifactRepository( String id, String url,
@ -34,31 +34,31 @@ public class DefaultArtifactRepositoryFactory
String snapshotPolicy, String checksumPolicy )
{
ArtifactRepository repo = null;
String snapPolicy = snapshotPolicy;
if ( globalSnapshotPolicy != null )
{
snapPolicy = globalSnapshotPolicy;
}
if ( snapPolicy == null )
{
snapPolicy = ArtifactRepository.SNAPSHOT_POLICY_NEVER;
}
String csumPolicy = checksumPolicy;
if ( globalChecksumPolicy != null )
{
csumPolicy = globalChecksumPolicy;
}
if ( csumPolicy == null )
{
csumPolicy = ArtifactRepository.CHECKSUM_POLICY_FAIL;
csumPolicy = ArtifactRepository.CHECKSUM_POLICY_WARN;
}
repo = new DefaultArtifactRepository( id, url, repositoryLayout, snapPolicy, csumPolicy );
return repo;
@ -68,7 +68,7 @@ public class DefaultArtifactRepositoryFactory
{
this.globalSnapshotPolicy = snapshotPolicy;
}
public void setGlobalChecksumPolicy( String checksumPolicy )
{
this.globalChecksumPolicy = checksumPolicy;

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" );