简体   繁体   English

在 Gradle 中使用 Nexus Repository 和其他 Repository

[英]Using Nexus Repository and Other Repository in Gradle

Can you help me with this problem please?你能帮我解决这个问题吗? I have to use in-house built-in dependencies which is hosted on Nexus for Netflix conductor project.我必须为Netflix conductor项目使用托管在Nexus上的内部内置依赖项。 I have setup the settings.xml which resolves the repository URL for Nexus repository.我已经设置了settings.xml ,它解析了Nexus存储库的存储库 URL。

I couldn't understand how the gradle will resolve these dependencies, currently my gradle is not searching for the in-house dependencies hosted on Nexus .我不明白 gradle 将如何解决这些依赖关系,目前我的 gradle 没有搜索托管在Nexus上的内部依赖关系。

What I am missing so that I can use our nexus repository as well as also using the Netflix provided repository?我缺少什么以便我可以使用我们的 nexus 存储库以及使用 Netflix 提供的存储库?

These are the repositories settings in build.gradle file.这些是 build.gradle 文件中的存储库设置。

repositories {
    mavenCentral()

    // oss-candidate for -rc.* verions:
    maven {
        url "https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates"
    }

    /**
     * This repository locates artifacts that don't exist in maven central but we had to backup from jcenter
     * The exclusiveContent
     */
    exclusiveContent {
        forRepository {
            maven {
                url "https://artifactory-oss.prod.netflix.net/artifactory/required-jcenter-modules-backup"
            }
        }
        filter {
            includeGroupByRegex "com\\.github\\.vmg.*"
        }
    }
}

I tried adding the following after the maven block but it didn't work.我尝试在maven块之后添加以下内容,但它没有用。

maven {
            name "server-id"
            url "https://repo.******.com/repository/***"
        }

Your response is appreciated.感谢您的回复。

Thank you!谢谢!

You can use multiple repositories by configuring them in both the settings.xml file and the build.gradle file.您可以通过在 settings.xml 文件和 build.gradle 文件中配置它们来使用多个存储库。

In the settings.xml file, you can specify the repositories that should be used for all projects that use the same settings.xml file.在 settings.xml 文件中,您可以指定应该用于所有使用相同 settings.xml 文件的项目的存储库。 For example, you can add a section to the settings.xml file and specify the URLs of the repositories that should be used.例如,您可以在 settings.xml 文件中添加一个部分,并指定应该使用的存储库的 URL。

In the build.gradle file, you can specify the repositories that should be used for the specific project.在 build.gradle 文件中,您可以指定应该用于特定项目的存储库。 You can do this by adding the following in the build.gradle file:您可以通过在 build.gradle 文件中添加以下内容来执行此操作:

repositories {
    maven {
        url 'http://my.custom.repo/maven2'
    }
    mavenLocal()
    mavenCentral()
}

n this example, the first repository is a custom repository, the second is the local repository, and the third is the central repository.在此示例中,第一个存储库是自定义存储库,第二个是本地存储库,第三个是中央存储库。

You can also define the repositories in the build.gradle file using the repositories block, this will override any repository defined in the settings.xml您还可以使用存储库块在 build.gradle 文件中定义存储库,这将覆盖设置中定义的任何存储库。xml

It's important to notice that repositories that are defined in the build.gradle file will have higher priority than those defined in the settings.xml file.请务必注意,build.gradle 文件中定义的存储库的优先级高于 settings.xml 文件中定义的存储库。

You can also use both repositories together by specifying them in both the settings.xml file and the build.gradle file, in this case the build.gradle file will have higher priority and will be used first to resolve dependencies.您还可以通过在 settings.xml 文件和 build.gradle 文件中指定它们来同时使用这两个存储库,在这种情况下,build.gradle 文件将具有更高的优先级,将首先用于解决依赖关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM