Reputation: 91
I am trying to delete old artifacts and the directory they live in from my .m2/repository directory. For example I have several versions of projectA: 4.7.0.222, 4.7.0.223, 4.7.0.224 etc. I only need to keep 4.7.0.224 project since it is the latest build.
How can I remove the older 2 versions 4.7.0.222 and 4.7.0.223 without manually deleting them? I have tried this command:
mvn dependency:purge-local-repository -DreResolve=false -DactTransitively=false -Dverbose=true
When I was in those project directories, everything was successful, but the items still remained. Does maven have any commands that are similar to a full linux "rm -rf" or No?
Upvotes: 0
Views: 2484
Reputation: 950
dependency:purge-local-repository
[...]
This goal is meant to delete all of the dependencies for the current project (or projects, in the case of a multimodule build) from the local repository.
[...]
[...]
To purge all the dependencies of a given groupId, use the
resolutionFuzziness
configuration parameter.If neither includes nor excludes are specified, all the dependencies of the current project are purged.
[...]
- file - Delete just the artifact's file.
- version - Delete the version directory containing this artifact.
- artifactId - Delete the artifactId directory containing this artifact.
- groupId - Delete the groupId directory structure containing this artifact.
To add the restriction that the [...] artifact not be deleted, add the
exclude
parameter as a comma-delimited list of groupId:artifactId pairs.
Upvotes: 1