如何从命令行确定Maven工件是否在我的存储库中? [英] How to determine if a Maven artifact is in my repo from command line?
问题描述
我想从命令行检查是否可以在存储库中找到某个坐标(groupId.artifactId.version
).
I would like to check from command line if a certain coordinate (groupId.artifactId.version
) can be found in a repository.
如果可能,是否可以使用局部坐标(例如artifactId.version
)完成?我可以指定回购吗?
If it is possible, can it be done with partial coordinates (e.g artifactId.version
)? Can I specify the repo?
我不要求解决方法-我可以直接在本地存储库中开始文件搜索,或者在POM中输入工件,然后等待错误,或者安装Nexus并通过UI搜索...
I do not ask for workarounds - I could simply start a file search in my local repo, or enter the artifact in a POM and wait for errors, or install Nexus and search over the UI...
这是一件方便的事情-一旦在CLI上,能够快速进行检查就很好了.
It is a convenience thing - once on the CLI, it would be nice to be able to check quickly.
推荐答案
以下是我认为最接近的方法:
Here's the closest I think you'll get:
mvn dependency:get -Dartifact=g:a:v -o -DrepoUrl=file://path/to/your/repo
我尝试过,如果工件(例如"junit:junit:4.8.2")在您的存储库中,它将成功,如果没有,则失败,但是您必须编写到本地存储库的完整路径作为网址.
I'v tried it, it succeeds if the artifact (e.g. "junit:junit:4.8.2") is in your repo and fails if it isn't, but you have to write the full path to your local repo as an URL.
关键是使用-o(脱机)标志,因为否则maven将始终检查中央存储库.
The key is to use the -o (offline) flag, because otherwise maven will always check the central repo.
这篇关于如何从命令行确定Maven工件是否在我的存储库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!