如何从命令行确定 Maven 工件是否在我的存储库中? [英] How to determine if a Maven artifact is in my repo from command line?

查看:20
本文介绍了如何从命令行确定 Maven 工件是否在我的存储库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从命令行检查是否可以在存储库中找到某个坐标 (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)来完成?我可以指定 repo 吗?

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屋!

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