Gradle Artifactory插件工件解析不起作用 [英] Gradle Artifactory plugin artifact resolution not working

查看:149
本文介绍了Gradle Artifactory插件工件解析不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取Gradle Artifactory插件来解决工件.

I am trying to get the Gradle Artifactory Plugin to resolve artifacts.

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

My build.gradle file is below with the being replaced with the correct hostname

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生成的.

However when this is run it fails to resolve the artifact. The dependency line was generated from Artifactory.

我打算使用旧的"发布机制.我的Gradle版本是2.0.

I am intending to use the "old" publish mechanism. My Gradle version is 2.0.

我尝试了带有maven2-default和gradle布局的人工仓库.

I have tried an artifactory repository with a maven2-default and a gradle layout.

可以在 http://textuploader.com/oljd

调试跟踪位于以下位置: http://filebin.ca/1ecmeQ7zYEIU/debug.txt

The debug trace can be found at http://filebin.ca/1ecmeQ7zYEIU/debug.txt

如果我改用Maven存储库即

If I instead use a maven repository i.e.

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

然后,工件将解决我因此在工件DSL代码中做错了什么,或者插件中有错误

Then the artifact will resolve I'm therefore either doing something wrong with the artifactory DSL code or there is a bug in the plugin

我现在也已经在Gradle 1.12和Gradle 2.1上进行了尝试,获得了相同的结果.

I have also now tried on Gradle 1.12 and Gradle 2.1 too with the same outcome.

推荐答案

我认为我找到了您要描述的问题的原因. Gradle Artifactory插件似乎可以正常运行. 执行"artifactoryPublish"任务时,将按预期从Artifactory中完成解析. 我还尝试将build.gradle任务(下载文件),依赖项配置(部署)和依赖项(如您的脚本中)添加到我的build.gradle中:

I think I found the cause of the issue you're describing. The Gradle Artifactory Plugin seems to function as expected. When executing the "artifactoryPublish" task, the the resolution is done from Artifactory as expected. I also tried adding to my build.gradle the task (downloadFile), dependency configuration (deploy) and the dependency (as in your script):

configurations {
   deploy 
}

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

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

当直接调用上面定义的downloadFile任务时,确实无法从Artifactory解析工件(除非您当然将Artifactory添加为存储库). 但是,如果您添加<<到任务声明:

When invoking the downloadFile task directly as it is defined above, the artifact will indeed not be resolved from Artifactory (unless of course you add that Artifactory as a repository). If however you add << to the task declaration:

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

Gradle会尝试从Artifactory解决人工制品. 添加<<"该任务等效于Gradle文档中描述的Task.doLast(): http://www.gradle.org/docs/current/dsl/org.gradle.api.Task.html

Gradle will attempt to resolve the Artifact from Artifactory. Adding "<<" to the task is equivalent to Task.doLast() as described in Gradle's documentation: http://www.gradle.org/docs/current/dsl/org.gradle.api.Task.html

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

All of the above seems to consistent with Gradle 2.x (with version 3.0.1 of the plugin), as well as Gradle 1.x (with all versions of the plugin).

这篇关于Gradle Artifactory插件工件解析不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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