Artifactory虚拟存储库无法解析Gradle-Artifactory插件

时间:2013-07-08 02:10:22

标签: gradle artifactory gradlew

所以,我最终试图让build-info-extractor-gradle插件工作......对不起发泄。 ; - )

我正在使用gradle包装器,指定gradle 1.6,artifactory 3.0.0,并尝试指定对build-info-extractor-gradle插件2.1.x-SNAPSHOT的依赖,因为这是{{3}对于gradle 1.5及以上。

我试图遵循这个specified version,但它必须过时,因为它仍然引用gradle 1.0并指定jfrog repo路径,它们不包含2.x版本的插件。


Artifactory Setup

  • local repo - “gradle-release-local” - 布局设置为gradle-default
  • remote repo - “gradle-plugins” - 稍微修改了jfrog导入 - 例如tutorial video
  • 虚拟仓库 - “gradle” - “gradle-release-local”和“gradle-plugins”

Gradle Setup

settings.gradle(从artifactory生成)

buildscript {
    repositories {
        maven {
            url 'http://artifactory.build.somewhere.com:8081/artifactory/gradle'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }

    }
    dependencies {
        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT'
    }
}

allprojects {
    apply plugin: 'artifactory'
}

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'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

我的存储库配置确实有效,如果我在本地上传jar,例如这就是我如何下载build-info-extractor-gradle jar。但是,所有依赖项都会失败,如您所见:

    $ gradlew tasks

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not resolve all dependencies for configuration 'classpath'.
    > Could not find commons-io:commons-io:2.0.1.
      Required by:
          unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT
    > Could not find org.apache.ivy:ivy:2.2.0.
      Required by:
          unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-
...
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

关于我的gradle配置或神器repo配置有什么问题的想法?为什么它不能解析远程存储库的外部依赖?我应该只添加mavenCentral吗?


更新

我将mavenCentral()添加到了存储库,只是为了看看会发生什么并得到:

$ gradlew tasks
Download http://repo1.maven.org/maven2/commons-io/commons-io/2.0.1/commons-io-2.0.1.pom
Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/15/commons-parent-15.pom
Download http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.pom
Download http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.pom
Download http://repo1.maven.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.pom

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration 'classpath'.
> Could not find org.jfrog.buildinfo:build-info-extractor:2.1.x-SNAPSHOT.
  Required by:
      unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

更新#2

开始新鲜。删除了mavenCentral()和本地上传的jar和pom,然后使用--info和--refresh-dependencies运行:

$ gradlew --refresh-dependencies -i tasks
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file 'D:\repos\some_build\build.gradle'.
Included projects: [root project 'some_build']
Evaluating root project 'some_build' using build file 'D:\repos\some_build\build.gradle'.
Compiling build file 'D:\repos\some_build\build.gradle' using BuildScriptClasspathScriptTransformer.
Resource missing. [HTTP GET: http://artifactory.build.somewhere.com:8081/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/2.1.0/build-info-extractor-gradle-2.1.0.pom]
Resource missing. [HTTP HEAD: http://artifactory.build.somewhere.com:8081/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/2.1.0/build-info-extractor-gradle-2.1.0.jar]

FAILURE: Build failed with an exception.

所以,很明显,我的虚拟“gradle”回购并没有找到工件。如何判断它是否正在搜索远程“gradle-plugins”仓库?

2 个答案:

答案 0 :(得分:4)

卫生署!事实证明,有两个非常重要的配置选项,禁用远程存储库解析,默认选择(我不记得检查/取消选中这些?)。

无论如何,这就是我所做的,为了最终通过我的虚拟仓库的解决方案让gradle-artifactory plugin正常工作:

  • 禁用全局离线模式
    1. 转到:Admin -> Configuration -> General
    2. 确保取消选择全局离线模式。您会在General Settings
    3. 中看到此选项
    4. 保存
  • 为虚拟仓库启用远程工件解析
    1. 转到: Admin -> Configuration -> Repositories -> {Edit the virtual repo} -> Advanced Settings
    2. 确保虚拟存储库已选择 Artifactory Requests可以检索远程工件
    3. 保存
  • gradle-plugins远程仓库添加到虚拟仓库
    1. 选择远程存储库中的New
    2. 为您的远程仓库指定名称,例如jfrog-gradle-plugins
    3. URL设为http://repo.jfrog.org/artifactory/gradle-plugins
    4. 保存
    5. 使用jfrog-gradle-plugins选项
    6. Selected Repositories远程仓库添加到您的虚拟仓库Edit
    7. 保存

将以下内容添加到build.gradle

buildscript {
    repositories {
        maven {
            url "${repositoryUrl}/libs-release"
        }
    }
    dependencies {
        classpath( group: 'org.jfrog.buildinfo',
                   name: 'build-info-extractor-gradle',
                   version: '2.2.2')
    }
}

将以下内容添加到gradle.properties

repositoryUrl = http://my.artifactory.server:8081/artifactory
repositoryUser = me
repositoryPassword = thisIsAPasswordStoredInMyUserDirectory

希望有助于任何人开始整合ArtifactoryGradle

在Artifactory

中调试工件分辨率的有用提示

使用trace REST API选项。例如:

http://repo.jfrog.org/artifactory/gradle-plugins/org/jfrog/buildinfo/build-info-extractor-gradle/2.2.2/build-info-extractor-gradle-2.2.2?trace

答案 1 :(得分:1)

看起来文档有误导性:(对不起。我现在正在添加澄清说明。

您正在查看的页面是一个全新(不同且更好)artifactory-publish插件的文档,但在代码中您使用的是经典artifactory插件(也没关系)。

请查看this page以获取artifactory插件的文档。

P.S。非常欢迎您尝试使用artifactory-publish插件,这太棒了。