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 リポジトリ パスを指定しているため、古いものである必要があります。


Artifactory セットアップ

  • ローカル リポジトリ - 「gradle-release-local」 - レイアウトを gradle-default に設定
  • リモートリポジトリ - 「gradle-plugins」 - jfrog インポートからわずかに変更 - 例: http://repo.jfrog.org/artifactory/gradle-plugins-snapshots
  • 仮想リポジトリ - 「gradle」 - 「gradle-release-local」および「gradle-plugins」

Gradle セットアップ

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構成またはartifactory 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

Doh! It turns out that there are two very important configuration options, which disable remote repository resolution, which are selected by default (I can't recall checking/unchecking these?).

Anyways, here is what I did, in order to finally get the gradle-artifactory plugin working, via resolution with my virtual repo:

  • Disable global offline mode
    1. Go to: Admin -> Configuration -> General
    2. Ensure that the Global Offline Mode is deselected. You'll see this option in General Settings
    3. Save
  • Enable remote artifact resolution for your virtual repo
    1. Go to: Admin -> Configuration -> Repositories -> {Edit the virtual repo} -> Advanced Settings
    2. Ensure that the virtual repository has Artifactory Requests Can Retrieve Remote Artifacts selected
    3. Save
  • Add the gradle-plugins remote repo to your virtual repo
    1. Choose New in remote repositories
    2. Give your remote repo a name, such as jfrog-gradle-plugins
    3. Set URL to http://repo.jfrog.org/artifactory/gradle-plugins
    4. Save
    5. Add the jfrog-gradle-plugins remote repo to your virtual repo's Selected Repositories, using the Edit option
    6. Save

Add following to build.gradle:

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

Add following to gradle.properties:

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

Hope that helps anyone struggling with getting started with integrating Artifactory and Gradle.

Helpful hint for debugging artifact resolution in Artifactory

Use the trace REST API option. For example:

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

PSartifactory-publishプラグインをぜひお試しください。素晴らしいです。

于 2013-07-08T09:41:28.753 に答える