如何从不知道工件名称或要卸载工件的组ID的脚本中执行mvn install的相反操作? [英] How can I execute the opposite of mvn install from a script that does not know the name of the artifact or group ID of the artifact being uninstalled?

查看:92
本文介绍了如何从不知道工件名称或要卸载工件的组ID的脚本中执行mvn install的相反操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来应该很容易,但是我还没有找到答案.如果我通过mvn install安装了工件,如何删除所说的工件?我尝试使用dependency:purge-local-repository,但是它只删除了依赖关系,而不是实际的工件.

有什么想法吗?如果有帮助,我正在使用maven 2.2.1.

我知道类似的问题,但是我对删除整个.m2存储库只是为了删除单个SNAPSHOT依赖项的答案不满意.另外,正如我提到的,purge-local-repository不起作用,因为它似乎只是删除了依赖关系,而不是实际的工件.

我可能不太清楚.考虑这个例子.我有一个称为my-artifact的SNAPSHOT工件.我的工件有两个依赖关系:我的依赖关系一和我的依赖关系二.我想编写一个无需删除pom.xml文件即可删除所有三个脚本的脚本.换句话说,我要清除my-dependency-one,my-dependency-two和 my-artifact ,而不必明确输入要删除my-artifact的Maven. /p>

在重复问题"的答案中,建议进入并从.m2存储库中手动删除工件.考虑到脚本在执行maven命令时不知道组名或工件名,因此这不是对这个问题的答案.我想要类似于dependency:purge-local-repository的东西,除了它不仅应该删除依赖关系,而且还应该删除工件本身.

基于评论的混乱,我猜测这是不可能的.如果不是,那将是一个可以接受的答案.

解决方案

这似乎是一种可行的方法(虽然有点笨拙).

这将删除项目的所有依赖项:

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

这将删除主要工件本身:

mvn dependency:purge-local-repository -DmanualInclude=${project.groupId}:${project.artifactId}:${project.version}

需要两个步骤,因为

手册包括:

groupId:artifactId 形式的依赖关系列表,应从本地存储库中删除/清除.请注意,使用此参数将取消清除当前项目依赖关系树的正常过程.如果使用此参数,则仅清除包含的工件. manualIncludes 参数不应与 includes/excludes 参数结合使用.

(请参见插件文档)

This sounds like it should be easy, but I've yet to find an answer. If I install an artifact with mvn install, how do I remove said artifact? I tried using dependency:purge-local-repository, but it only removes the dependencies - not the actual artifact.

Any ideas? I'm using maven 2.2.1 if that helps.

Edit: I'm aware of the similar question, but I'm unsatisfied with the answer of removing my entire .m2 repo just to remove a single SNAPSHOT dependency. Also, as I mentioned, purge-local-repository doesn't work since it only seems to be removing the dependencies and not the actual artifact.

Edit 2: I'm probably not being very clear. Consider this example. I have a SNAPSHOT artifact that is called my-artifact. my-artifact has two dependencies: my-dependency-one and my-dependency-two. I would like to write a script that will delete all three without me having to parse the pom.xml file. In other words, I'd like to purge my-dependency-one, my-dependency-two, AND my-artifact without having to explicitly type into maven that I want to delete my-artifact.

In the answers for the 'duplicate questions' it suggests going in and manually deleting the artifacts from the .m2 repo. That is not an answer to this question given that the script does not knew the group or artifact name when it executes the maven command. I want something similar to dependency:purge-local-repository except that it should not only remove the dependencies, but the artifact itself.

I'm guessing based on the confusion in the comments that this is just not possible. If it isn't that would be an acceptable answer.

解决方案

Here's one way that seems to work (though a bit clumsy).

This removes all dependencies of the project:

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

And this removes the main artifact itself:

mvn dependency:purge-local-repository -DmanualInclude=${project.groupId}:${project.artifactId}:${project.version}

Two steps are required, because

manualIncludes:

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.

(see the plugin doc)

这篇关于如何从不知道工件名称或要卸载工件的组ID的脚本中执行mvn install的相反操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆