o Fixed functionality to disable dependency resolution and download for things like clean:clean.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2004-09-22 03:31:41 +00:00
parent 5f23120ff6
commit 8e6c7b0424
3 changed files with 47 additions and 24 deletions

View File

@ -29,6 +29,8 @@ public class MavenGoalExecutionContext
private String goalName;
private boolean requiresDependencies;
public MavenGoalExecutionContext( MavenSession session, String goalName )
{
this.session = session;
@ -138,4 +140,15 @@ public class MavenGoalExecutionContext
{
this.goalName = goalName;
}
public void requiresDependencies( boolean requiresDependencies )
{
this.requiresDependencies = requiresDependencies;
}
public boolean requiresDependencies()
{
return requiresDependencies;
}
}

View File

@ -36,34 +36,37 @@ public class DependencyDownloadPhase
public void execute( MavenGoalExecutionContext context )
throws GoalExecutionException
{
ArtifactResolver artifactResolver = null;
try
if(context.requiresDependencies())
{
// Once this is a property component there will be an assembly phase for
// this and we won't have to do this.
artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
ArtifactResolver artifactResolver = null;
for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
try
{
Artifact artifact = (Artifact) it.next();
// Once this is a property component there will be an assembly phase for
// this and we won't have to do this.
artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
artifactResolver.resolve( artifact,
context.getRemoteRepositories(),
context.getLocalRepository() );
for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
artifactResolver.resolve( artifact,
context.getRemoteRepositories(),
context.getLocalRepository() );
}
}
catch ( ComponentLookupException e )
{
throw new GoalExecutionException( "Can't lookup artifact resolver: ", e );
}
catch ( ArtifactResolutionException e )
{
throw new GoalExecutionException( "Can't resolve artifact: ", e );
}
finally
{
context.release( artifactResolver );
}
}
catch ( ComponentLookupException e )
{
throw new GoalExecutionException( "Can't lookup artifact resolver: ", e );
}
catch ( ArtifactResolutionException e )
{
throw new GoalExecutionException( "Can't resolve artifact: ", e );
}
finally
{
context.release( artifactResolver );
}
}
}

View File

@ -37,12 +37,17 @@ public class DependencyResolutionPhase
public void execute( MavenGoalExecutionContext context )
throws GoalExecutionException
{
boolean requiresDependencies = false;
for ( Iterator iterator = context.getResolvedGoals().iterator(); iterator.hasNext(); )
{
String goalName = (String) iterator.next();
if ( context.getMojoDescriptor( goalName ).requiresDependencyResolution() )
MojoDescriptor mojoDescriptor = context.getMojoDescriptor(goalName);
if ( mojoDescriptor.requiresDependencyResolution() )
{
requiresDependencies = true;
try
{
resolveTransitiveDependencies( context );
@ -55,6 +60,8 @@ public class DependencyResolutionPhase
break;
}
}
context.requiresDependencies(requiresDependencies);
}
private void resolveTransitiveDependencies( MavenGoalExecutionContext context )