Author: pgier
Date: Thu Oct 25 05:04:29 2012
New Revision: 1401976
URL: http://svn.apache.org/viewvc?rev=1401976&view=rev
Log:
[MDEP-386] Undo the split between automated purge and manual purge.
o Some more refactoring to make the mojo more robust.
o Update the IT settings so that certain ITs are skipped for Maven 3.0.4.
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-bad-pom/invoker.properties
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-non-transitive/verify.bsh
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-reresolve/invoker.properties
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/invoker.properties
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/test.properties
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/purging-local-repository.apt.vm
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-bad-pom/invoker.properties
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-bad-pom/invoker.properties?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-bad-pom/invoker.properties
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-bad-pom/invoker.properties
Thu Oct 25 05:04:29 2012
@@ -1 +1,3 @@
invoker.goals =
${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository
+# Only works works with Maven 3.0.x except for 3.0.4
+invoker.maven.version = 3.0.0+, !3.0.4
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-non-transitive/verify.bsh
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-non-transitive/verify.bsh?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-non-transitive/verify.bsh
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-non-transitive/verify.bsh
Thu Oct 25 05:04:29 2012
@@ -6,7 +6,7 @@ System.out.println( "Checking for absenc
if ( depDir.exists() )
{
- throw new Exception( "Directory was not deleted: " + purgedDir );
+ throw new Exception( "Directory was not deleted: " + depDir );
}
File transitiveDepDir = new File( localRepositoryPath,
"org/apache/maven/its/dependency/purge-local-repository-2/1.0" );
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-reresolve/invoker.properties
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-reresolve/invoker.properties?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-reresolve/invoker.properties
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-reresolve/invoker.properties
Thu Oct 25 05:04:29 2012
@@ -1 +1,3 @@
-invoker.goals =
${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository
+invoker.goals =
${project.groupId}:${project.artifactId}:${project.version}:resolve
${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository
+# Does not work in Maven 3.0.4 due to the resolveAlways operation not
correctly forcing a new download
+invoker.maven.version = !3.0.4
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/invoker.properties
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/invoker.properties?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/invoker.properties
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/invoker.properties
Thu Oct 25 05:04:29 2012
@@ -1 +1,3 @@
invoker.goals =
${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository
+# Does not work in Maven 3.0.4 due to the resolveAlways operation not
correctly forcing a new download
+invoker.maven.version = !3.0.4
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/test.properties
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/test.properties?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/test.properties
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/it/purge-local-repository-version-range/test.properties
Thu Oct 25 05:04:29 2012
@@ -1 +1,2 @@
reResolve = true
+actTransitively = true
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java
Thu Oct 25 05:04:29 2012
@@ -21,19 +21,22 @@ package org.apache.maven.plugin.dependen
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import
org.apache.maven.plugin.dependency.utils.resolvers.DefaultArtifactsResolver;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter;
import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
import org.codehaus.plexus.util.FileUtils;
@@ -43,19 +46,18 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* Remove the project dependencies from the local repository, and optionally
re-resolve them.
- * Note: since 2.6 this mojo acts only on the current project, and not on all
projects in the reactor.
*
* @author jdcasey
* @version $Id$
* @since 2.0
*/
-@Mojo( name = "purge-local-repository", requiresDependencyResolution =
ResolutionScope.TEST, threadSafe = true )
+@Mojo( name = "purge-local-repository", threadSafe = true )
public class PurgeLocalRepositoryMojo
extends AbstractMojo
{
@@ -69,11 +71,31 @@ public class PurgeLocalRepositoryMojo
public static final String GROUP_ID_FUZZINESS = "groupId";
/**
- * The current project
+ * The current Maven project.
*/
@Component
- protected MavenProject project;
+ private MavenProject project;
+ /**
+ * The list of dependencies in the form of groupId:artifactId which should
BE deleted/purged from the local
+ * repository. Note that using this parameter will deactivate the normal
process for purging the current project
+ * dependency tree. If this parameter is used, only the included artifacts
will be purged. The manualIncludes
+ * parameter should not be used in combination with the includes/excludes
parameters.
+ *
+ * @since 2.6
+ */
+ @Parameter
+ private List<String> manualIncludes;
+
+ /**
+ * Comma-separated list of groupId:artifactId entries, which should be
used to manually include artifacts for
+ * deletion. This is a command-line alternative to the
<code>manualIncludes</code> parameter, since List parameters
+ * are not currently compatible with CLI specification.
+ *
+ * @since 2.6
+ */
+ @Parameter( property = "manualInclude" )
+ private String manualInclude;
/**
* The list of dependencies in the form of groupId:artifactId which should
BE deleted/refreshed.
@@ -124,7 +146,7 @@ public class PurgeLocalRepositoryMojo
* List of Remote Repositories used by the resolver
*/
@Parameter( defaultValue = "${project.remoteArtifactRepositories}",
readonly = true, required = true )
- protected List<ArtifactRepository> remoteRepos;
+ protected List<ArtifactRepository> remoteRepositories;
/**
* The artifact resolver used to re-resolve dependencies, if that option
is enabled.
@@ -133,6 +155,12 @@ public class PurgeLocalRepositoryMojo
private ArtifactResolver resolver;
/**
+ * The artifact metadata source used to resolve dependencies
+ */
+ @Component
+ private ArtifactMetadataSource metadataSource;
+
+ /**
* Determines how liberally the plugin will delete an artifact from the
local repository. Values are: <br/>
* <ul>
* <li><b>file</b> - Eliminate only the artifact's file.</li>
@@ -170,47 +198,72 @@ public class PurgeLocalRepositoryMojo
@Parameter( property = "snapshotsOnly", defaultValue = "false" )
private boolean snapshotsOnly;
- public void execute()
- throws MojoExecutionException, MojoFailureException
+ /**
+ * Includes only direct project dependencies.
+ */
+ private class DirectDependencyFilter
+ implements ArtifactFilter
{
- @SuppressWarnings( "unchecked" )
- Set<Artifact> projectArtifacts = actTransitively ?
project.getArtifacts() : project.getDependencyArtifacts();
- ArtifactFilter artifactFilter = createPurgeArtifactsFilter();
+ private Artifact projectArtifact;
- Set<Artifact> artifactsToPurge = filterArtifacts( project,
projectArtifacts, artifactFilter );
+ private Set<Artifact> directDependencyArtifacts;
- if ( artifactsToPurge.isEmpty() )
+ /**
+ * Default constructor
+ *
+ * @param directDependencyArtifacts Set of Artifact objects which
represent the direct dependencies of the
+ * project
+ */
+ public DirectDependencyFilter( Artifact projectArtifact, Set<Artifact>
directDependencyArtifacts )
{
- getLog().info( "No artifacts included for purge for project: " +
project.getId() );
- return;
+ this.projectArtifact = projectArtifact;
+ this.directDependencyArtifacts = directDependencyArtifacts;
}
- verbose( "Purging dependencies for project: " + project.getId() );
- purgeArtifacts( artifactsToPurge );
+ public boolean include( Artifact artifact )
+ {
+ if ( artifactsGAMatch( artifact, projectArtifact ) )
+ {
+ return true;
+ }
+ for ( Artifact depArtifact : directDependencyArtifacts )
+ {
+ if ( this.artifactsGAMatch( artifact, depArtifact ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- if ( this.reResolve )
+ /*
+ * Compare the groupId:artifactId of two artifacts.
+ */
+ private boolean artifactsGAMatch( Artifact artifact1, Artifact
artifact2 )
{
- final boolean STOP_ON_FAILURE = false;
- DefaultArtifactsResolver artifactsResolver =
- new DefaultArtifactsResolver( resolver,
this.localRepository, this.remoteRepos, STOP_ON_FAILURE );
-
- // First re-resolve all the poms
- Set<Artifact> pomArtifacts = new HashSet<Artifact>();
- for ( Artifact artifact : artifactsToPurge )
+ if ( artifact1 == artifact2 )
{
- Artifact pomArtifact =
- factory.createArtifact( artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion(),
- null, "pom" );
- pomArtifacts.add( pomArtifact );
+ return true;
}
- artifactsResolver.resolve( pomArtifacts, getLog() );
- // Then re-resolve the artifacts
- artifactsResolver.resolve( artifactsToPurge, getLog() );
+ if ( !artifact1.getGroupId().equals( artifact2.getGroupId() ) )
+ {
+ getLog().debug( "Different groupId: " + artifact1 + " " +
artifact2 );
+ return false;
+ }
+ if ( !artifact1.getArtifactId().equals( artifact2.getArtifactId()
) )
+ {
+ getLog().debug( "Different artifactId: " + artifact1 + " " +
artifact2 );
+ return false;
+ }
+ return true;
}
}
+ /**
+ * Includes only artifacts that do not use system scope
+ */
private class SystemScopeExcludeFilter
implements ArtifactFilter
{
@@ -220,6 +273,9 @@ public class PurgeLocalRepositoryMojo
}
}
+ /**
+ * Includes only snapshot artifacts
+ */
private class SnapshotsFilter
implements ArtifactFilter
{
@@ -229,11 +285,143 @@ public class PurgeLocalRepositoryMojo
}
}
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ if ( !StringUtils.isEmpty( manualInclude ) )
+ {
+ manualIncludes = this.parseIncludes( manualInclude );
+ }
+ // If it's a manual purge, the only step is to delete from the local
repo
+ if ( manualIncludes != null && manualIncludes.size() > 0 )
+ {
+ manualPurge( manualIncludes );
+ return;
+ }
+
+ Set<Artifact> dependencyArtifacts = null;
+
+ try
+ {
+ dependencyArtifacts = project.createArtifacts( factory, null, null
);
+ }
+ catch ( InvalidDependencyVersionException e )
+ {
+ throw new MojoFailureException( "Unable to purge dependencies due
to invalid dependency version ", e );
+ }
+
+ ArtifactFilter artifactFilter = createPurgeArtifactsFilter(
dependencyArtifacts );
+
+ Set<Artifact> resolvedArtifactsToPurge =
+ getFilteredResolvedArtifacts( project, dependencyArtifacts,
artifactFilter );
+
+ if ( resolvedArtifactsToPurge.isEmpty() )
+ {
+ getLog().info( "No artifacts included for purge for project: " +
project.getId() );
+ return;
+ }
+
+ verbose( "Purging dependencies for project: " + project.getId() );
+ purgeArtifacts( resolvedArtifactsToPurge );
+
+ if ( reResolve )
+ {
+ try
+ {
+ reResolveArtifacts( project, resolvedArtifactsToPurge,
artifactFilter );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ String failureMessage = "Failed to refresh project
dependencies for: " + project.getId();
+ MojoFailureException failure = new MojoFailureException(
failureMessage );
+ failure.initCause( e );
+
+ throw failure;
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ String failureMessage = "Failed to refresh project
dependencies for: " + project.getId();
+ MojoFailureException failure = new MojoFailureException(
failureMessage );
+ failure.initCause( e );
+
+ throw failure;
+ }
+ }
+ }
+
+ /**
+ * Purge/Delete artifacts from the local repository according to the given
patterns.
+ *
+ * @param inclusionPatterns
+ * @throws MojoExecutionException
+ */
+ private void manualPurge( List<String> includes )
+ throws MojoExecutionException
+ {
+ for ( String gavPattern : includes )
+ {
+ if ( StringUtils.isEmpty( gavPattern ) )
+ {
+ getLog().debug( "Skipping empty gav pattern: " + gavPattern );
+ continue;
+ }
+
+ String relativePath = gavToPath( gavPattern );
+ if ( StringUtils.isEmpty( relativePath ) )
+ {
+ continue;
+ }
+
+ File purgeDir = new File( localRepository.getBasedir(),
relativePath );
+ if ( purgeDir.exists() )
+ {
+ getLog().debug( "Deleting directory: " + purgeDir );
+ try
+ {
+ FileUtils.deleteDirectory( purgeDir );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Unable to purge
directory: " + purgeDir );
+ }
+ }
+ }
+ }
+
+ /**
+ * Convert a groupId:artifactId:version to a file system path
+ *
+ * @param gav, the groupId:artifactId:version string
+ * @return
+ */
+ private String gavToPath( String gav )
+ {
+ if ( StringUtils.isEmpty( gav ) )
+ {
+ return null;
+ }
+
+ String[] pathComponents = gav.split( ":" );
+
+ StringBuffer path = new StringBuffer( pathComponents[0].replace( '.',
'/' ) );
+
+ for ( int i = 1; i < pathComponents.length; ++i )
+ {
+ path.append( "/" + pathComponents[i] );
+ }
+
+ return path.toString();
+ }
+
/**
* Create the includes exclude filter to use when resolving and purging
dependencies Also excludes any "system"
* scope dependencies
+ *
+ * @param dependencyArtifacts The dependency artifacts to use as a
reference if we're excluding transitive
+ * dependencies
+ * @return
*/
- private ArtifactFilter createPurgeArtifactsFilter()
+ private ArtifactFilter createPurgeArtifactsFilter( Set<Artifact>
dependencyArtifacts )
{
AndArtifactFilter andFilter = new AndArtifactFilter();
@@ -250,20 +438,25 @@ public class PurgeLocalRepositoryMojo
{
this.includes = parseIncludes( this.include );
}
- if ( !StringUtils.isEmpty( this.exclude ) )
+ if ( this.includes != null )
{
- this.excludes = parseIncludes( this.exclude );
+ andFilter.add( new PatternIncludesArtifactFilter( includes ) );
}
- if ( this.includes != null )
+ if ( !StringUtils.isEmpty( this.exclude ) )
{
- andFilter.add( new PatternIncludesArtifactFilter( includes ) );
+ this.excludes = parseIncludes( this.exclude );
}
if ( this.excludes != null )
{
andFilter.add( new PatternExcludesArtifactFilter( excludes ) );
}
+ if ( !actTransitively )
+ {
+ andFilter.add( new DirectDependencyFilter( project.getArtifact(),
dependencyArtifacts ) );
+ }
+
return andFilter;
}
@@ -286,42 +479,64 @@ public class PurgeLocalRepositoryMojo
return includes;
}
- /**
- * Filter and resolve the set of artifacts. If we're not doing transitive
dependency resolution, we just resolve the
- * artifact file in the local repo.
- *
- * @param project
- * @param artifacts
- * @param artifactFilter
- * @return
- */
- private Set<Artifact> filterArtifacts( MavenProject project, Set<Artifact>
artifacts, ArtifactFilter artifactFilter )
+ private Set<Artifact> getFilteredResolvedArtifacts( MavenProject project,
Set<Artifact> artifacts,
+ ArtifactFilter filter )
{
- Set<Artifact> filteredArtifacts = new HashSet<Artifact>();
+ try
+ {
+ ArtifactResolutionResult result =
+ resolver.resolveTransitively( artifacts,
project.getArtifact(), localRepository, remoteRepositories,
+ metadataSource, filter );
+
+ @SuppressWarnings( "unchecked" )
+ Set<Artifact> resolvedArtifacts = result.getArtifacts();
+
+ return resolvedArtifacts;
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ getLog().info( "Unable to resolve all dependencies for : " +
e.getGroupId() + ":" + e.getArtifactId() + ":"
+ + e.getVersion()
+ + ". Falling back to non-transitive mode for
initial artifact resolution." );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ getLog().info( "Unable to resolve all dependencies for : " +
e.getGroupId() + ":" + e.getArtifactId() + ":"
+ + e.getVersion()
+ + ". Falling back to non-transitive mode for
initial artifact resolution." );
+ }
+
+ Set<Artifact> resolvedArtifacts = new LinkedHashSet<Artifact>();
+ // Resolve the only poms here instead of the actual artifacts, because
the files will be deleted during the
+ // purge anyway
for ( Artifact artifact : artifacts )
{
- if ( artifactFilter.include( artifact ) )
+ if ( filter.include( artifact ) )
{
- filteredArtifacts.add( artifact );
+ try
+ {
+ resolvedArtifacts.add( artifact );
+ resolver.resolve( artifact, remoteRepositories,
localRepository );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ getLog().debug( "Unable to resolve artifact: " + artifact
);
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ getLog().debug( "Unable to resolve artifact: " + artifact
);
+ }
}
}
- return filteredArtifacts;
+ return resolvedArtifacts;
}
- /**
- * Delete the artifacts from the local repo
- *
- * @param artifacts
- * @throws MojoFailureException
- */
private void purgeArtifacts( Set<Artifact> artifacts )
throws MojoFailureException
{
- int i = 0;
for ( Artifact artifact : artifacts )
{
- i++;
- verbose( "Purging artifact " + i + '/' + artifacts.size() + ": " +
artifact.getId() );
+ verbose( "Purging artifact: " + artifact.getId() );
File deleteTarget = findDeleteTarget( artifact );
@@ -335,25 +550,85 @@ public class PurgeLocalRepositoryMojo
}
catch ( IOException e )
{
- throw new MojoFailureException( this, "Cannot delete
dependency from the local repository: "
- + artifact.getId(), "Failed to delete: " +
deleteTarget );
+ getLog().warn( "Unable to purge local repository location:
" + deleteTarget, e );
}
}
else
{
if ( !deleteTarget.delete() )
{
- throw new MojoFailureException( this, "Cannot delete
dependency from the local repository: "
- + artifact.getId(),
"Failed to delete: " + deleteTarget );
+ getLog().warn( "Unable to purge local repository location:
" + deleteTarget );
}
}
artifact.setResolved( false );
}
}
+ private void reResolveArtifacts( MavenProject project, Set<Artifact>
artifacts, ArtifactFilter filter )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+
+ // Always need to re-resolve the poms in case they were purged along
with the artifact
+ // because Maven 2 will not automatically re-resolve them when
resolving the artifact
+ for ( Artifact artifact : artifacts )
+ {
+ try
+ {
+ Artifact pomArtifact =
+ factory.createArtifact( artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion(),
+ null, "pom" );
+ resolver.resolveAlways( pomArtifact, remoteRepositories,
localRepository );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ verbose( e.getMessage() );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ verbose( e.getMessage() );
+ }
+ }
+
+ List<Artifact> missingArtifacts = new ArrayList<Artifact>();
+
+ for ( Artifact artifact : artifacts )
+ {
+ verbose( "Resolving artifact: " + artifact.getId() );
+
+ try
+ {
+ resolver.resolveAlways( artifact,
project.getRemoteArtifactRepositories(), localRepository );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ verbose( e.getMessage() );
+ missingArtifacts.add( artifact );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ verbose( e.getMessage() );
+ missingArtifacts.add( artifact );
+ }
+ }
+
+ if ( missingArtifacts.size() > 0 )
+ {
+ String message = "required artifacts missing:\n";
+ for ( Artifact missingArtifact : missingArtifacts )
+ {
+ message += " " + missingArtifact.getId() + "\n";
+ }
+ message += "\nfor the artifact:";
+
+ throw new ArtifactResolutionException( message,
project.getArtifact(),
+
project.getRemoteArtifactRepositories() );
+ }
+ }
+
private File findDeleteTarget( Artifact artifact )
{
- File deleteTarget = artifact.getFile();
+ // Use localRepository.pathOf() in case artifact.getFile() is not set
+ File deleteTarget = new File( localRepository.getBasedir(),
localRepository.pathOf( artifact ) );
if ( GROUP_ID_FUZZINESS.equals( resolutionFuzziness ) )
{
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/purging-local-repository.apt.vm
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/purging-local-repository.apt.vm?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/purging-local-repository.apt.vm
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/purging-local-repository.apt.vm
Thu Oct 25 05:04:29 2012
@@ -120,6 +120,11 @@ mvn dependency:purge-local-repository -D
the build. This goal is normally safe at the end of the build, or as
part of the build clean process.
+ WARNING, using this goal during a build can cause build failures if
+ dependencies are removed from the local repo, but are needed at a later point
+ in the build. It is recommended that this goal only be used outside of a
build
+ or during the clean process.
+
+---+
mvn dependency:manual-purge-local-repository -Dinclude=org.apache:apache
+---+
Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt?rev=1401976&r1=1401975&r2=1401976&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt Thu Oct
25 05:04:29 2012
@@ -68,13 +68,10 @@ Maven Dependency Plugin
*{{{./list-mojo.html}dependency:list}} alias for resolve that lists the
dependencies for this project.
-
*{{{./manual-purge-local-repository-mojo.html}dependency:manual-purge-local-repository}}
tells Maven to clear
- specific dependencies/directories from the local repository.
-
*{{{./properties-mojo.html}dependency:properties}} set a property for each
project dependency containing the
to the artifact on the file system.
- *{{{./purge-local-repository-mojo.html}dependency:purge-local-repository}}
tells Maven to clear all dependency-artifact
+ *{{{./purge-local-repository-mojo.html}dependency:purge-local-repository}}
tells Maven to clear dependency artifact
files out of the local repository, and optionally re-resolve them.
*{{{./resolve-mojo.html}dependency:resolve}} tells Maven to resolve all
dependencies and displays the version.