I would like to check from command line if a certain coordinate (groupId.artifactId.version
) can be found in a repository.
我想从命令行检查是否可以在存储库中找到某个坐标(groupId.artifactId.version)。
If it is possible, can it be done with partial coordinates (e.g artifactId.version
)? Can I specify the repo?
如果可能,可以用部分坐标(例如artifactId.version)来完成吗?我可以指定回购吗?
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...
我没有要求解决方法 - 我可以简单地在我的本地仓库中启动文件搜索,或者在POM中输入工件并等待错误,或者安装Nexus并在UI上搜索...
It is a convenience thing - once on the CLI, it would be nice to be able to check quickly.
这是一个方便的事情 - 一旦在CLI上,能够快速检查将是很好的。
2 个解决方案
#1
20
Here's the closest I think you'll get:
这是我认为你最接近的:
mvn dependency:get -Dartifact=g:a:v -o -DrepoUrl=file://path/to/your/repo
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.
我试过了,如果工件(例如“junit:junit:4.8.2”)在你的仓库中,它就会成功,如果不存在则会失败,但是你必须把你本地仓库的完整路径写成URL 。
The key is to use the -o (offline) flag, because otherwise maven will always check the central repo.
关键是使用-o(离线)标志,否则maven将始终检查*仓库。
#2
1
I've never heard about something like this. Probably get
goal of dependency
plugin is somehow close, but it's still not exactly what you're looking for. I'm afraid there's no such thing. However, wrting own Maven plugin that does what you want could be pretty simple. New artifact resolution mechanism in Maven 3, called Aether, has really good and simple API.
我从来没有听说过这样的事情。可能获得依赖插件的目标在某种程度上接近,但它仍然不是你正在寻找的。我担心没有这样的事情。但是,使用自己想要的Maven插件可能非常简单。 Maven 3中的新神器解析机制,称为Aether,具有非常好的简单API。
Anyway, look at dependency plugin:
无论如何,看看依赖插件:
http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html
http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html
#1
20
Here's the closest I think you'll get:
这是我认为你最接近的:
mvn dependency:get -Dartifact=g:a:v -o -DrepoUrl=file://path/to/your/repo
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.
我试过了,如果工件(例如“junit:junit:4.8.2”)在你的仓库中,它就会成功,如果不存在则会失败,但是你必须把你本地仓库的完整路径写成URL 。
The key is to use the -o (offline) flag, because otherwise maven will always check the central repo.
关键是使用-o(离线)标志,否则maven将始终检查*仓库。
#2
1
I've never heard about something like this. Probably get
goal of dependency
plugin is somehow close, but it's still not exactly what you're looking for. I'm afraid there's no such thing. However, wrting own Maven plugin that does what you want could be pretty simple. New artifact resolution mechanism in Maven 3, called Aether, has really good and simple API.
我从来没有听说过这样的事情。可能获得依赖插件的目标在某种程度上接近,但它仍然不是你正在寻找的。我担心没有这样的事情。但是,使用自己想要的Maven插件可能非常简单。 Maven 3中的新神器解析机制,称为Aether,具有非常好的简单API。
Anyway, look at dependency plugin:
无论如何,看看依赖插件:
http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html
http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html