如何从本地maven repo中删除项目工件?

时间:2022-02-04 19:54:56

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.

在本地多模块项目上运行mvn install时,它会构建项目工件并将其安装到本地存储库中。 mvn clean似乎清理了我的项目特定目标目录。

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.

我使用什么命令与maven从本地仓库卸载我的项目模块?例如我的项目输出foo-0.1.jar和bar-0.2.jar我希望那些从我的本地仓库中删除,而不必去那里并自己删除它们。

3 个解决方案

#1


3  

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:

您可以从本地存储库中清除工件,但为什么要这样做呢?除此之外,你可以通过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


40  

mvn build-helper:remove-project-artifact

#3


2  

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.

最好是实现一个发布策略,即只要正在开发的工件附加SNAPSHOT版本。当您运行安装时,Maven会自动更新本地存储库中的工件。完成开发后,删除SNAPSHOT并释放版本(即通过部署)。如果需要进一步开发,您可以增加版本号并使用SNAPSHOT再次附加它。

#1


3  

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:

您可以从本地存储库中清除工件,但为什么要这样做呢?除此之外,你可以通过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


40  

mvn build-helper:remove-project-artifact

#3


2  

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.

最好是实现一个发布策略,即只要正在开发的工件附加SNAPSHOT版本。当您运行安装时,Maven会自动更新本地存储库中的工件。完成开发后,删除SNAPSHOT并释放版本(即通过部署)。如果需要进一步开发,您可以增加版本号并使用SNAPSHOT再次附加它。