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

View File

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

View File

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

View File

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

View File

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

View File

@ -56,7 +56,7 @@ public class DefaultArtifactRepositoryFactory
if ( csumPolicy == null ) if ( csumPolicy == null )
{ {
csumPolicy = ArtifactRepository.CHECKSUM_POLICY_FAIL; csumPolicy = ArtifactRepository.CHECKSUM_POLICY_WARN;
} }
repo = new DefaultArtifactRepository( id, url, repositoryLayout, snapPolicy, csumPolicy ); 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() + ")" ); 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 ) public void updateScope( Artifact artifact, String scope )
{ {
logger.debug( indent + artifact.getId() + " (settings scope to: " + scope + ")" ); logger.debug( indent + artifact.getId() + " (settings scope to: " + scope + ")" );

View File

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

View File

@ -27,8 +27,16 @@ import org.apache.maven.artifact.Artifact;
public class CyclicDependencyException public class CyclicDependencyException
extends ArtifactResolutionException extends ArtifactResolutionException
{ {
private Artifact artifact;
public CyclicDependencyException( String message, Artifact artifact ) public CyclicDependencyException( String message, Artifact artifact )
{ {
super( message, 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.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -150,6 +151,13 @@ public class DefaultArtifactCollector
Set artifacts = source.retrieve( child.getArtifact(), localRepository, remoteRepositories ); Set artifacts = source.retrieve( child.getArtifact(), localRepository, remoteRepositories );
child.addDependencies( artifacts, filter ); 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 ) catch ( ArtifactMetadataRetrievalException e )
{ {
child.getArtifact().setDependencyTrail( node.getDependencyTrail() ); child.getArtifact().setDependencyTrail( node.getDependencyTrail() );
@ -226,6 +234,9 @@ public class DefaultArtifactCollector
case ResolutionListener.OMIT_FOR_NEARER: case ResolutionListener.OMIT_FOR_NEARER:
listener.omitForNearer( node.getArtifact(), replacement ); listener.omitForNearer( node.getArtifact(), replacement );
break; break;
case ResolutionListener.OMIT_FOR_CYCLE:
listener.omitForCycle( node.getArtifact() );
break;
case ResolutionListener.UPDATE_SCOPE: case ResolutionListener.UPDATE_SCOPE:
listener.updateScope( node.getArtifact(), replacement.getScope() ); listener.updateScope( node.getArtifact(), replacement.getScope() );
break; break;
@ -248,11 +259,14 @@ public class DefaultArtifactCollector
private final int depth; private final int depth;
private final ResolutionNode parent;
public ResolutionNode( Artifact artifact ) public ResolutionNode( Artifact artifact )
{ {
this.artifact = artifact; this.artifact = artifact;
this.depth = 0; this.depth = 0;
this.parents = Collections.EMPTY_LIST; this.parents = Collections.EMPTY_LIST;
this.parent = null;
} }
public ResolutionNode( Artifact artifact, ResolutionNode parent ) public ResolutionNode( Artifact artifact, ResolutionNode parent )
@ -262,6 +276,7 @@ public class DefaultArtifactCollector
this.parents = new ArrayList(); this.parents = new ArrayList();
this.parents.addAll( parent.parents ); this.parents.addAll( parent.parents );
this.parents.add( parent.getKey() ); this.parents.add( parent.getKey() );
this.parent = parent;
} }
public Artifact getArtifact() public Artifact getArtifact()
@ -289,7 +304,7 @@ public class DefaultArtifactCollector
{ {
a.setDependencyTrail( getDependencyTrail() ); 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 ) ); children.add( new ResolutionNode( a, this ) );
@ -299,8 +314,13 @@ public class DefaultArtifactCollector
public List getDependencyTrail() public List getDependencyTrail()
{ {
List path = new ArrayList( parents ); List path = new LinkedList();
path.add( artifact.getId() ); ResolutionNode node = this;
while ( node != null )
{
path.add( 0, node.getArtifact().getId() );
node = node.parent;
}
return path; return path;
} }

View File

@ -42,6 +42,8 @@ public interface ResolutionListener
int MANAGE_ARTIFACT = 7; int MANAGE_ARTIFACT = 7;
int OMIT_FOR_CYCLE = 8;
void testArtifact( Artifact node ); void testArtifact( Artifact node );
void startProcessChildren( Artifact artifact ); void startProcessChildren( Artifact artifact );
@ -55,4 +57,6 @@ public interface ResolutionListener
void updateScope( Artifact artifact, String scope ); void updateScope( Artifact artifact, String scope );
void manageArtifact( Artifact artifact, Artifact replacement ); 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 ); this.projectArtifact = createArtifact( "project", "1.0", null );
} }
public void testCircularDependencyNotIncludingCurrentProject() // works, but we don't fail on cycles presently
public void disabledtestCircularDependencyNotIncludingCurrentProject()
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
ArtifactSpec a = createArtifact( "a", "1.0" ); 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 throws ArtifactResolutionException
{ {
ArtifactSpec a = createArtifact( "a", "1.0" ); ArtifactSpec a = createArtifact( "a", "1.0" );