diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalExecutionContext.java b/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalExecutionContext.java index 4cb0e4d002..8b42ccd718 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalExecutionContext.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalExecutionContext.java @@ -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; + } + } \ No newline at end of file diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyDownloadPhase.java b/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyDownloadPhase.java index e519c42ae4..0878ae9485 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyDownloadPhase.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyDownloadPhase.java @@ -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 ); } } } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyResolutionPhase.java b/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyResolutionPhase.java index 6f1b70274b..9d17e18dc6 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyResolutionPhase.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyResolutionPhase.java @@ -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 )