Reputation: 1685
In attempting to publish my set of plain Java libraries on Bintray using the Gradle Bintray plugin, I got the following error upon running the 'bintrayUpload' task:
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'task ':bintrayUpload'' with class 'com.jfrog.bintray.gradle.BintrayUploadTask_Decorated' to class 'com.jfrog.bintray.gradle.BintrayUploadTask'
at com.jfrog.bintray.gradle.BintrayUploadTask.getCachedRepositories(BintrayUploadTask.groovy:663)
at com.jfrog.bintray.gradle.BintrayUploadTask_Decorated.getCachedRepositories(Unknown Source)
at com.jfrog.bintray.gradle.BintrayUploadTask.getRepository(BintrayUploadTask.groovy:683)
at com.jfrog.bintray.gradle.BintrayUploadTask.checkPackageAlreadyCreated(BintrayUploadTask.groovy:510)
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure5.doCall(BintrayUploadTask.groovy:255)
at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure5.doCall(BintrayUploadTask.groovy)
at com.jfrog.bintray.gradle.BintrayUploadTask.bintrayUpload(BintrayUploadTask.groovy:470)
The publish tasks work perfectly; it's just the Bintray upload that is failing.
Each library is a submodule in a root project.
The Maven/Bintray part of the Gradle file in one of my submodules looks like this:
//Bintray
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}
def bintrayPropertiesFile = rootProject.file("bintray.properties")
def bintrayProperties = new Properties()
bintrayProperties.load(new FileInputStream(bintrayPropertiesFile))
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication){
from components.java
groupId bintrayProperties['bintrayRepository']
artifactId project.name
version rootProject.libraryVersion
}
}
}
apply plugin: 'com.jfrog.bintray'
bintray {
user = bintrayProperties['bintrayUser']
key = bintrayProperties['bintrayKey']
publications = ['mavenJava']
pkg {
repo = bintrayProperties['bintrayRepository']
name = project.name
userOrg = bintrayProperties['bintrayOrganization']
licenses = [bintrayProperties['bintrayLicense']]
vcsUrl = bintrayProperties['bintrayVcs']
version {
name = rootProject.libraryVersion
released = new Date()
}
}
}
What am I doing wrong in my Gradle build file? Thanks in advance.
Upvotes: 1
Views: 2702
Reputation: 1685
Add the following to your root project's build.gradle
:
buildscript {
...
dependencies {
...
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
}
}
apply plugin: 'com.jfrog.bintray'
I would love to be enlightened as to why this fixes it, but it does.
Upvotes: 3