bintray / gradle-bintray-plugin

Apache License 2.0
1.28k stars 197 forks source link

Gradle Kotlin DSL BintrayExtension unresolved #301

Open LukasPaczos opened 5 years ago

LukasPaczos commented 5 years ago

Hey, I'm trying to port our Bintray plugin setup from Groovy to Kotlin, but I'm running into:

Extension of type 'BintrayExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, KotlinJvmProjectExtension, KotlinTestsRegistry, DefaultArtifactPublicationSet, ReportingExtension, SourceSetContainer, JavaPluginExtension, BintrayExtension, PublishingExtension]

It's surprising to me that the extension is listed, but cannot be resolved. Do you think this might be incompatibility on your side or an issue with our Gradle setup?

Here's the setup: gradle-bintray.gradle.kts

import com.jfrog.bintray.gradle.BintrayExtension

apply(plugin = "maven-publish")
apply(plugin = "com.jfrog.bintray")

configure<PublishingExtension> {
  publications {
    register("MyPublication", MavenPublication::class) {
      ...
    }
  }
}

configure<BintrayExtension> {
  setPublications("MyPublication")
  ...
}

project's build.gradle.kts

plugins {
  kotlin("jvm")
}

dependencies {
  implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41")
}

project.apply {
  from("$rootDir/gradle/gradle-bintray.gradle.kts")
}

root's build.gradle.kts

buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41")
    classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
  }
}

allprojects {
  repositories {
    google()
    jcenter()
  }
}
nidomiro commented 4 years ago

I'm running into the same problem ...

GuilhE commented 4 years ago

Same here! https://stackoverflow.com/q/62239488/1423773 @LukasPaczos did you solved it?

teyckmans commented 4 years ago

@GuilhE tested with an empty project, not sure why but if you apply the bintray plugin like this it works:

import com.jfrog.bintray.gradle.BintrayPlugin
plugins.apply(BintrayPlugin::class.java)

This is also the way I am doing it in this build: https://github.com/teyckmans/ui-rig/blob/master/ui-rig-core/build.gradle.kts

GuilhE commented 4 years ago

@GuilhE tested with an empty project, not sure why but if you apply the bintray plugin like this it works:

import com.jfrog.bintray.gradle.BintrayPlugin
plugins.apply(BintrayPlugin::class.java)

This is also the way I am doing it in this build: https://github.com/teyckmans/ui-rig/blob/master/ui-rig-core/build.gradle.kts

It worked! :pray: Running gradle assemble gives me a successful build.

messi-wpy commented 4 years ago

however ,when I import it ,i get Unresolved reference: jfrog this error,anyone know why?

GuilhE commented 4 years ago

You'll also have to add this: classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5") So you'll endup with:

buildscript {
    repositories { jcenter() }
    dependencies {
        classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
    }
}

plugins.apply(BintrayPlugin::class.java) //https://github.com/bintray/gradle-bintray-plugin/issues/301
messi-wpy commented 4 years ago

You'll also have to add this: classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5") So you'll endup with:

buildscript {
    repositories { jcenter() }
    dependencies {
        classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
    }
}

plugins.apply(BintrayPlugin::class.java) //https://github.com/bintray/gradle-bintray-plugin/issues/301

yeah , i have,

GuilhE commented 4 years ago

You'll also have to replace it in your project build.gradle:

dependencies {
        classpath "com.android.tools.build:gradle:4.0.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5"
    }
}

plugins {
    id "maven-publish"
//    id "com.jfrog.bintray" version "1.8.5"
}
asarkar commented 4 years ago

You do not need to add the plugin JAR as a dependency. Here's a working version: https://github.com/asarkar/grpc-test/blob/master/build.gradle.kts

mars885 commented 3 years ago

@messi-wpy Did you manage to solve it? I have a similar error like you. Unfortunately, the above solution does not work for me.