查找其他哪些项目将此项目用作Maven依赖项? [英] Find what other projects use this project as a maven dependency?

查看:84
本文介绍了查找其他哪些项目将此项目用作Maven依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Artifactory存储我们的Maven生成的Java工件.我们有许多相互依赖的相互关联的项目.使用maven或Artifactory可以选择单个工件并查找所有依赖该工件的项目吗?

We use Artifactory to store our maven generated java artifacts. We have many interrelated projects that depend on each other. Is it possible with maven or with Artifactory to look pick a single artifact and look for all projects that have that as a dependency?

在下面的示例中,我想查找哪些项目使用了artifact1 v1.0.0.我希望能够使用maven/Artifactory来找到一个事实,即artifact2依赖于此版本的依赖关系,但找不到不存在的artifact3/4.理想情况下,如果我只是在寻找工件1的用途,而不论其版本如何,找到工件2也是一件好事.

In the example below, I want to find what projects use artifact1 v1.0.0. I would like to be able to use maven/Artifactory to find the fact that artifact2 depends on this version of the dependency, but not find artifact3/4 which don't. Ideally it would also be nice to find artifact2 if I was just looking for uses of artifact1 regardless of version.

    <project>
        <groupId>mygroup</groupId>
        <artifactId>artifact1</artifactId>
        <version>1.0.0</version>
    </project>


    <project>
        <groupId>mygroup</groupId>
        <artifactId>artifact2</artifactId>
        <version>1.0.0</version>

        <dependencies>
            <dependency>
                <groupId>mygroup</groupId>
                <artifactId>artifact1</artifactId>
                <version>1.0.0</version>
            </dependency>
        </dependencies>
    </project>

    <project>
        <groupId>mygroup</groupId>
        <artifactId>artifact3</artifactId>
        <version>1.0.0</version>

        <dependencies>
            <dependency>
                <groupId>mygroup</groupId>
                <artifactId>artifact1</artifactId>
                <version>1.1.0</version>
            </dependency>
        </dependencies>
    </project>

    <project>
        <groupId>mygroup</groupId>
        <artifactId>artifact4</artifactId>
        <version>1.0.0</version>

        <dependencies>
            <dependency>
                <groupId>mygroup</groupId>
                <artifactId>otherartifact</artifactId>
                <version>1.0.0</version>
            </dependency>
        </dependencies>
    </project>

推荐答案

这几乎是您首先使用Artifactory的主要原因之一. Artifactory以其 AQL 的形式提供了非常广泛的搜索功能,它正是您所要的.

This is pretty much one of the main reasons why you would use Artifactory in the first place. Artifactory provides a very extensive search capability in the form of its AQL, which does exactly what you're asking for.

作为您的案例运行类似的示例:

As an example for your case running something like:

builds.find(
        {"module.dependency.item.name":{"$match":"*artifact1*"}}
    ).include("module.artifact.name")

将返回所有具有Artifact1作为依赖项的构建(您也可以添加"$and"子句以将其限制为特定版本的Arifact1),最后的include将返回作为一部分的所有工件.具有Artifact1作为依赖项的模块的位置(因此您将在这里看到Artifact2)

will return all builds that had Artifact1 as a dependency (you can also add an "$and" clause to limit this to a specific version of Arifact1), the include at the end will return all artifacts that were part of the module that had Artifact1 as a dependency (so that's where you will see Artifact2 in your case)

这是我在名为multi-module-build的简单Maven构建上运行此查询时获得的示例输出,该构建具有多个模块,其中一个模块(multi3)具有名为multi1的依赖项:

Here is an example output I got when running this query on a simple maven build called multi-module-build that had several modules where one of them (multi3) had a dependency called multi1:

"results" : [ {
    "build.created" : "2016-03-10T09:08:51.283+02:00",
    "build.created_by" : "admin",
    "build.name" : "multi-module-build",
    "build.number" : "10",
    "build.url" : "http://localhost:9090/jenkins/job/multi-shmulti/10/",
    "modules" : [ {
    "artifacts" : [ {
            "artifact.name" : "multi3-3.6-SNAPSHOT.war"
        }, {
            "artifact.name" : "multi3-3.6-SNAPSHOT.pom"
        } ]
    } ]
 } ]

这篇关于查找其他哪些项目将此项目用作Maven依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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