【问题标题】:Gradle Artifactory plugin artifact resolution not workingGradle Artifactory 插件工件分辨率不起作用
【发布时间】:2014-12-18 04:07:13
【问题描述】:

我正在尝试让 Gradle Artifactory 插件解决工件。

我的 build.gradle 文件在下面,替换为正确的主机名

buildscript {
    repositories {
        maven { url 'http://jcenter.bintray.com' }
    }
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.0.1')
    }
}

apply plugin: 'com.jfrog.artifactory'

artifactory {
   contextUrl = 'http://<URL>:8081/artifactory'   //The base Artifactory URL if not overridden by the publisher/resolver

   resolve {
      repository {
         repoKey = 'training'
         maven = true
      }
   }
}

configurations {
   deploy 
}

dependencies {
   deploy group: 'test', name: 'PolicyAdmin', version: '1.0', ext: 'ear'
}

task downloadFile {
    def fileExec = configurations.deploy.getSingleFile()
}

但是,当它运行时,它无法解析工件。依赖行是从 Artifactory 生成的。

我打算使用“旧”发布机制。我的 Gradle 版本是 2.0。

我尝试了一个带有 maven2-default 和 gradle 布局的工件存储库。

堆栈跟踪可以在http://textuploader.com/oljd找到

调试跟踪可以在http://filebin.ca/1ecmeQ7zYEIU/debug.txt找到

如果我改为使用 maven 存储库,即

repositories {
   maven {
      url 'http://<URL>:8081/artifactory/repo'
   } 
}

然后工件将解决我因此要么对工件 DSL 代码做错了事,要么插件中存在错误

我现在也尝试了 Gradle 1.12 和 Gradle 2.1,结果相同。

【问题讨论】:

    标签: gradle artifactory


    【解决方案1】:

    我想我找到了您所描述问题的原因。 Gradle Artifactory 插件似乎按预期运行。 执行“artifactoryPublish”任务时,解析是按预期从 Artifactory 完成的。 我还尝试将任务(downloadFile)、依赖项配置(deploy)和依赖项(如在您的脚本中)添加到我的 build.gradle:

    configurations {
       deploy 
    }
    
    dependencies {
       deploy group: 'test', name: 'PolicyAdmin', version: '1.0', ext: 'ear'
    }
    
    task downloadFile {
       def fileExec = configurations.deploy.getSingleFile()
    }
    

    当直接调用上面定义的 downloadFile 任务时,工件确实不会从 Artifactory 解析(当然,除非您将该 Artifactory 添加为存储库)。 但是,如果您将

    task downloadFile << {
       def fileExec = configurations.deploy.getSingleFile()
    }
    

    Gradle 将尝试从 Artifactory 解析 Artifact。 如 Gradle 的文档中所述,将“http://www.gradle.org/docs/current/dsl/org.gradle.api.Task.html

    以上所有内容似乎都与 Gradle 2.x(带有插件的 3.0.1 版本)以及 Gradle 1.x(带有所有版本的插件)一致。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-29
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-19
      • 2016-09-23
      相关资源
      最近更新 更多