8

When upgrading to Gradle 4.10, I faced the following error when attempting to compile:

Execution failed for task ':buildSrc:compileKotlin'.
> Could not resolve all files for configuration ':buildSrc:kotlinCompilerPluginClasspath'.
   > Could not find org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.2.60.
     Searched in the following locations: file:/Users/<user-name>/.gradle/caches/4.10/embedded-kotlin-repo-1.2.60-2/repo/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.2.60/kotlin-scripting-compiler-embeddable-1.2.60.jar
     Required by:
         project :buildSrc
   > Could not find org.jetbrains.kotlin:kotlin-sam-with-receiver:1.2.60.
     Required by:
         project :buildSrc

Note that I was using buildSrc as part of my Gradle compilation process.

eskatos
  • 4,174
  • 2
  • 40
  • 42
Juan Andrés Diana
  • 2,215
  • 3
  • 25
  • 36

2 Answers2

20

This is due to a breaking change in Kotlin DSL 1.0:

The kotlin-dsl plugin now requires a repository to be declared

With Kotlin 1.2.60, the Kotlin Gradle Plugin driving the kotlin compiler requires extra dependencies that aren't required by Gradle Kotlin DSL scripts alone and aren't embedded into Gradle.

This can be fixed by adding a repository that contains Kotlin compiler dependencies on the project where the kotlin-dsl plugin is applied: repositories { jcenter() }

Community
  • 1
  • 1
Eric Wendelin
  • 43,147
  • 9
  • 68
  • 92
13

build.gradle.kts should contain

plugins {
    `kotlin-dsl`
}
// Required since Gradle 4.10+.
repositories {
    jcenter()
}
Abhay Pratap
  • 1,886
  • 11
  • 15