5

所以,我想尽办法让 build-info-extractor-gradle 插件工作......抱歉发泄。;-)

我正在使用 gradle 包装器,指定 gradle 1.6、artifactory 3.0.0,并尝试指定对 build-info-extractor-gradle 插件 2.1.x-SNAPSHOT 的依赖,因为这是gradle 1.5 及更高版本的指定版本.

我试图按照这个教程视频,但它必须是过时的,因为它仍然引用 gradle 1.0 并指定不包含 2.x 版本的插件的 jfrog repo 路径。


工件设置

  • 本地仓库 - “gradle-release-local” - 布局设置为 gradle-default
  • 远程仓库 - “gradle-plugins” - 从 jfrog 导入稍微修改 - 例如http://repo.jfrog.org/artifactory/gradle-plugins-snapshots
  • 虚拟仓库 - “gradle” - “gradle-release-local” 和 “gradle-plugins”

摇篮设置

settings.gradle(从工件生成)

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”存储库?

4

2 回答 2

6

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

无论如何,这就是我所做的,为了最终让gradle-artifactory 插件工作,通过我的虚拟仓库的解析:

  • 禁用全局离线模式
    1. 去:Admin -> Configuration -> General
    2. 确保取消选择全局离线模式。您将在General Settings
    3. 节省
  • 为您的虚拟存储库启用远程工件解析
    1. 去: Admin -> Configuration -> Repositories -> {Edit the virtual repo} -> Advanced Settings
    2. 确保虚拟存储库选择了Artifactory Requests Can Retrieve Remote Artifacts
    3. 节省
  • gradle-plugins远程仓库添加到您的虚拟仓库
    1. New在远程存储库中选择
    2. 为您的远程仓库命名,例如jfrog-gradle-plugins
    3. 设置URLhttp://repo.jfrog.org/artifactory/gradle-plugins
    4. 节省
    5. 使用选项将远程仓库添加jfrog-gradle-plugins到您的虚拟仓库Selected RepositoriesEdit
    6. 节省

将以下内容添加到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 中调试工件分辨率的有用提示

使用跟踪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

于 2014-01-30T02:31:43.193 回答
1

看起来文档具有误导性 :( 对此感到抱歉。我现在添加一个澄清说明。

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

请查看此页面artifactory以获取插件的文档。

PS非常欢迎您尝试该artifactory-publish插件,它很棒。

于 2013-07-08T09:41:28.753 回答