【问题标题】:Gradle Artifactory plugin errorGradle Artifactory 插件错误
【发布时间】:2015-08-18 12:40:02
【问题描述】:

我的 gradle 版本是 2.2.1。

我正在尝试在 gradle (apply plugin: 'artifactory') 中使用 artifactory 插件

这是我的代码:

buildscript {
    repositories {
        maven {
            url 'http://172.14.3.93/artifactory/plugins-release'

        }

    }
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9')
    }
}

allprojects {
    apply plugin: 'artifactory'
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            maven = true

        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            maven = true

        }
    }
}

当我运行 gradle build 时,这是我得到的:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Workspace\GradleConfiguration\build.gradle' line: 100

* What went wrong:
A problem occurred evaluating root project 'GradleConfiguration'.
> Failed to apply plugin [id 'artifactory']
   > Could not find method add() for arguments [artifactoryPublish, class org.jfrog.gradle.plugin.artifactory.extractor.BuildInfoTask] on task set.

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

另外,当我删除与工件相关的所有代码并只留下apply plugin: 'artifactory' 时,我收到此错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\OnRights_Workspace\GradleConfiguration\build.gradle' line: 86

* What went wrong:
A problem occurred evaluating root project 'GradleConfiguration'.
> Failed to apply plugin [id 'artifactory']
   > Plugin with id 'artifactory' not found.

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

【问题讨论】:

    标签: eclipse gradle artifactory


    【解决方案1】:

    您的插件版本太旧。尝试使用最新的 (3.1.1)。

    【讨论】:

    • 好的,我升级了,我的问题是,我升级后是否需要删除 jcenter() 存储库?我目前正在使用 mavenCentral() 和 artifactory
    • 如果您将 Artifactory 与插件一起使用,您应该在 buildscript{} 中有 jcenter,并且脚本本身中根本没有存储库。该插件负责解析和部署。
    • 当前版本为“4.4.2”
    • 在写这篇文章的时候(正好一年前)最新的是 3.1.1。是的,我们正在工作:)
    【解决方案2】:

    buildscript 块告诉 Gradle 它应该在哪里寻找插件。你告诉它它应该只搜索http://172.14.3.93/artifactory/plugins-release

    您是否 100% 确定“artifactory”插件实际上托管在那里?

    如果你把 jcenter 放在那里,比如the instructions say,效果会更好吗?

    buildscript {
       repositories {
         jcenter()
       }
       dependencies {
         classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.0"
       }
    }
    apply plugin: "com.jfrog.artifactory"
    

    【讨论】:

    • 正如我所说,即使我删除了 buildscript 并只保留了 apply 插件,错误仍然存​​在
    • 是的。这是预期的。请不要删除 buildscript 块,Gradle 需要它来查找插件。只需准确添加说明中的内容,让我们知道它是有效的。我链接的页面中的整个块,标题为“构建脚本 sn-p 以用于所有 Gradle 版本”。您也可以尝试另一个名为“构建脚本 sn-p 以用于 Gradle 2.1 及更高版本”。
    • 我不明白为什么在从工件站点生成的构建脚本中,它默认告诉 gradle 在工件中查找插件...
    猜你喜欢
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2017-02-07
    • 2022-10-24
    • 1970-01-01
    • 2014-10-29
    • 1970-01-01
    相关资源
    最近更新 更多