How to do remove a projects artifacts from the loc

2020-02-09 02:34发布

问题:

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.

回答1:

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.



回答2:

mvn build-helper:remove-project-artifact


回答3:

Best is to implement a release strategy, i.e. as long as the artifacts under development appending the version with SNAPSHOT. Maven then automatically updates the artifacts in the local repository when you run install. Once you have completed the development you remove the SNAPSHOT and release the version (i.e. via deploy). If further development is required you could increase the version number and append it again with SNAPSHOT.



标签: maven maven-3