I'm using Gradle wrapper 6.6, but I keep getting t...
# announcements
c
I'm using Gradle wrapper 6.6, but I keep getting this error when compiling my Gradle Kotlin DSL buildSrc code. Why is it using a much older Gradle version for buildSrc? Or is the message bogus?
Copy code
* What went wrong:
An exception occurred applying plugin request [id: 'org.jetbrains.kotlin.jvm', version: '1.4.0']
> Failed to apply plugin [id 'org.jetbrains.kotlin.jvm']
   > The current Gradle version 5.2.1 is not compatible with the Kotlin Gradle plugin. Please use Gradle 5.3 or newer, or the previous version of the Kotlin plugin.
b
are you sure your wrapper is updated? Looks like gradle on os is 6.6, but wraper is set to 5.3
or the other way arround, depending on how you invoke the build
c
On the top-level project, I have this gradle-wrapper.properties distributionUrl.
distributionUrl=https\:<//services.gradle.org/distributions/gradle-6.6-all.zip>
j
What command are you running?
b
gradle build != gradlew build
j
try ./gradlew clean build
c
I know that. Android Studio is attempting to run some unit tests.
It's also clearly referencing Gradle 6.6 if I do ./gradlew clean build...
Copy code
> Task :internal-gradle-plugins:compileDepsKotlin
The `kotlin-dsl` plugin applied to project ':internal-gradle-plugins' enables experimental Kotlin compiler features. For more information see <https://docs.gradle.org/6.6/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin>

> Task :internal-gradle-plugins:compileKotlin
The `kotlin-dsl` plugin applied to project ':internal-gradle-plugins' enables experimental Kotlin compiler features. For more information see <https://docs.gradle.org/6.6/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin>
b
Ah, i see
Try tweaking your settings to this to make sure android studio is using wrapper too
c
Looks like it is.
I'm only having this issue inside the buildSrc folder of one module.
b
Oooh, right
that's a different story
you cannot use kotlin 1.4 for buildSrc as it needs to match kotlin used by gradle distro (latest currently is 1.3.72)
c
Thank you! That makes sense. Ok. I downgraded to 1.3.72 and now it's saying in a series of errors that I need a dependency on stdlib. I do though.
1
This is what I have in my buildSrc
build.gradle.kts
file:
Copy code
plugins {
    kotlin("jvm") version "1.3.72"
}

repositories {
    jcenter()
}
The module
build.gradle.kts
includes stdlib-jdk8 under dependencies.
b
buildSrc does not share main module's dependencies
so you need to declare it again explicitly
c
Oh, that must be it.
j
Copy code
plugins {
    `kotlin-dsl`
}

repositories {
    jcenter()
}
👍 1
b
@Javier what does kotlin-dsl plugin do exactly? Seen it in many places, but don' have a clue what it's used for
b
yes, but why do you need a plugin?
or does it manage the koltin dependencies for ou automatically?
j
You need it to use Kotlin inside buildSrc and generate accessors