Gradle artifactory插件说“无法投射对象”org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'...“ [英] Gradle artifactory plugin saying "Cannot cast object 'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'..."

查看:225
本文介绍了Gradle artifactory插件说“无法投射对象”org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'...“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是获取artifactory插件的配置:

  buildscript {
repositories {
mavenCentral )
maven {url'http://jcenter.bintray.com'}
}
依赖关系{
classpath组:'org.jfrog.buildinfo',名称:'build -info-extractor-gradle',version:'3.0.1'
}
}
apply plugin:'com.jfrog.artifactory'
apply plugin:'ivy-publish '

...一些发布规范的东西...

我跑gradle(2.3),我得到:

 >无法应用插件[id'com.jfrog.artifactory'] 
>不能与类的org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'上课org.jfrog.gradle.plugin.artifactory投对象org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention@6b6c7be4。 dsl.ArtifactoryPluginConvention'

当然看起来像一个类路径问题,但我确实有这个项目和一个兄弟项目使用这套相同的gradle / artifactory配置,一个工作,另一个不工作。两者都是同一顶级项目的一部分。相同的JDK(1.8.0_20)。同一个Gradle。同样的东西。



我很困惑...

在遇到其他人有同样问题的情况下回答此问题。问题是,当我将各种位添加到兄弟项目时,这意味着我有两个项目定义了buildscript部分。

  buildscript {
...
依赖关系{
classpath组:'org.jfrog .buildinfo',名称:'build-info-extractor-gradle',版本:'3.0.1'
}
}

显然,在类路径中存在两个不同版本的依赖关系,因此出现了错误。



解决方案是将buildscript位移动到主项目中,以便这些依赖项只定义一次。


Here's the configuration to get the artifactory plugin:

buildscript {
    repositories {
        mavenCentral()
        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'
apply plugin:'ivy-publish'

...some publish spec stuff...

I run gradle (2.3) and I get:

> Failed to apply plugin [id 'com.jfrog.artifactory']
   > Cannot cast object 'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention@6b6c7be4' with class 'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention' to class 'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'

Certainly looks like a classpath issue, but I literally have this project and a sibling project using this same set of gradle/artifactory configurations and one works and the other does not. Both are part of the same top level project. Same JDK (1.8.0_20). Same Gradle. Same everything.

I'm baffled...

解决方案

Answering this in case someone else has the same issue. The problem was that when I added the various bits to the sibling project that meant I had two projects defining the buildscript {} section.

buildscript {
    ...
    dependencies {
        classpath group:'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.0.1'
    }
}

Apparently that caused two different versions of the dependency to exist in the classpath, hence the error.

The solution was to move the buildscript bit into the master project so those dependencies are only defined once.

这篇关于Gradle artifactory插件说“无法投射对象”org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'...“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆