Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do remove a projects artifacts from the local maven repo?

Tags:

When running mvn install on a local multi module project it builds and install the projects artifacts into the local repo. mvn clean seems to clean up my project specific target directories.

What command do I use with maven to get it to uninstall my projects modules from the local repo? for example my projects outputs foo-0.1.jar and bar-0.2.jar I want those removed from my local repo without having to go in there and delete them myself.

like image 535
ams Avatar asked Jan 31 '13 17:01

ams


People also ask

How do I delete an artifact in Maven?

If you want to explicitly remove a single artifact from the cache, use purge-local-repository with the manualInclude parameter. For example, from the command line: mvn dependency:purge-local-repository -DmanualInclude="groupId:artifactId, ..."

How do I clean up my local Maven repository?

To clear/delete your local maven repository cache, simply delete the . m2/repository folder. The local repository path can also be configured in Maven setting. xml (either the global or the user one).

Which command can you use to clear up old artifacts in a Maven project?

When running mvn install on a local multi module project it builds and install the projects artifacts into the local repo. mvn clean seems to clean up my project specific target directories.

How do I delete a library in Maven?

Local maven repository is just a directory located in $HOME/. m2/repository/ . Locate your library there and just remove the directory where the files are stored.


2 Answers

mvn build-helper:remove-project-artifact 
like image 128
Dmitry Trifonov Avatar answered Sep 23 '22 08:09

Dmitry Trifonov


You can purge artifacts from your local repository, but why do you like to do this? Apart from that you can do that via maven-dependency-plugin:

This will purge all project- and dependency artifacts

mvn dependency:purge-local-repository -DreResolve=false 

This can be influenced by supplemental command line arguments (see the documentation) for further details.

like image 35
khmarbaise Avatar answered Sep 20 '22 08:09

khmarbaise