Gradle Artifactory plugin artifact resolution not working

有些话、适合烂在心里 提交于 2019-12-12 04:52:12

问题


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

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()
}

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

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

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

The stack trace can be found at http://textuploader.com/oljd

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

If I instead use a maven repository i.e.

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

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

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


回答1:


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()
}

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 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

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).



来源:https://stackoverflow.com/questions/26512005/gradle-artifactory-plugin-artifact-resolution-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!