简体   繁体   English

使用人工制品从Gradle中拉出人工制品或依赖项的问题

[英]Issues pulling artifacts or dependencies using Gradle from artifactory

So, here is what I want to do: 所以,这是我想做的:

  1. push a library to artifactory using gradle -> Done 使用gradle将库推入工件->完成
  2. get the service to pull the dependent library from artifactory -> Issues 获取从工件中提取依赖库的服务->问题

From what I understand it can be done using Gradle Artifactory Plugin. 据我了解,可以使用Gradle Artifactory插件来完成。

Below is the sample build.gradle : 以下是示例build.gradle:

buildscript {
    repositories {
             jcenter()
        }

    }
    dependencies {
        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.0'
    }
}


apply plugin: "com.jfrog.artifactory"
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'

group = 'a.b.c'

allprojects {
    apply plugin: 'artifactory'
}

configurations{
...
}

dependencies {
    compile group: 'a', name: 'b', version:'c'
    compile group: 'x', name: 'y', version:'z'
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'gradle-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
            ivy {
                ivyLayout = '[organization]/[module]/ivy-[revision].xml'
                artifactLayout = '[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]'
                mavenCompatible = false
            }
        }
    }
    resolve {
        repository {
            repoKey = 'gradle'
            repoKey = 'gradle-release-local'
            maven = true

        }
    }
}

Sample Settings.gradle 样本Settings.gradle

rootProject.name = ‘partnering'
includeFlat ‘a'
project(‘:a').projectDir=new File(settings,'../a')

Note: 注意:

In dependencies, as you can see 如您所见,在依赖项中

  1. compile group: 'a', name: 'b', version:'c' This needs repoKey = gradle-release-local 编译组:'a',名称:'b',版本:'c'这需要repoKey = gradle-release-local
  2. compile group: 'x', name: 'y', version:'z' This needs repoKey = grade 编译组:“ x”,名称:“ y”,版本:“ z”这需要repoKey = grade

ERROR: 错误:

  1. Cannot resolve external dependency abc because no repositories are defined. 无法解析外部依赖项abc,因为未定义任何存储库。
  2. However I can see the library is already present in artifactory 但是我可以看到该库已经存在于人工制品中

Can somebody please let me with this issue. 有人可以让我解决这个问题吗?

gradle is a virtual repository, it aggregates number of other repositories in it. gradle是一个虚拟存储库,它汇总了其中的其他存储库数量。

In the repositories configuration, make sure that gradle virtual repository contains the gradle-release-local repository. 在存储库配置中,确保gradle虚拟存储库包含gradle-release-local存储库。

Once done, only leave one repoKey for resolution, gradle . 完成后,仅保留一个repoKey进行解析,即gradle

When you want to pull dependencies from a remote repository, you need to define them in build.gradle . 当您要从远程存储库中提取依赖项时,需要在build.gradle定义它们。 Pushing libraries to a repository is isolated from pulling libraries. 将库推送到存储库与提取库是隔离的。

The following example contains two examples. 下面的示例包含两个示例。 One for maven central and and one for a custom repository. 一个用于Maven Central ,另一个用于自定义存储库。

repositories {
    mavenCentral()
    maven {
        url "http://www.edwardraff.com/maven-repo/"
    }
}

Look into the documentation . 查看文档

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

相关问题 如何使用gradle将Artifactory中的工件从项目类路径中提取出来? - How to pull artifacts from Artifactory to project classpath using gradle? 将工件从本地Gradle工件存储库部署到JCenter / MavenCentral - Deploying artifacts from a local Gradle artifactory repository to JCenter/MavenCentral 在Gradle Task中拉出和运行依赖项 - Pulling and Running Dependencies in Gradle Task Gradle 没有拉下新的依赖项 - Gradle not pulling down new dependencies 从Artifactory远程存储库下载大型工件 - Downloading Large Artifacts from Artifactory Remote Repository IntelliJ / Maven不会更新Artifactory中的工件 - IntelliJ/Maven not updating artifacts from Artifactory 从 Maven Artifactory 中提取所有工件,而不仅仅是 JAR 工件 - Pull all artifacts from Maven Artifactory instead of just JAR artifacts JAR 从 JFrog Artifactory 下载到 Gradle 缓存但不显示在项目和外部依赖项中 - JAR from JFrog Artifactory downloading to the Gradle cache but not displaying in Project and External Dependencies 如何使用jenkins发布构建动作将工件从工件组部署到jfrog工件 - How to deploy an artifact from group of artifacts to jfrog artifactory using jenkins post build action Gradle没有从存储库中拉出.jar - Gradle not pulling .jar from repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM