Failure in Intellij and Jenkins since migration to kotlin 1.2.60

After upgrading to kotlin 1.2.60, I’ve started receiving the following Warning in Intellij (2018.2.1)

  • gradle 4.5.1
  • mavenCentral repo

Gradle import errors
Warning:Warning:root project ‘my-service’: Unable to build Kotlin project configuration
Details: java.lang.reflect.InvocationTargetException: null
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ‘:kotlinCompilerPluginClasspath’.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Cannot resolve external dependency org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.2.60 because no repositories are defined.
Required by:
project :

Warning:Warning:root project ‘my-service’: Unable to build Kotlin project configuration
Details: java.lang.reflect.InvocationTargetException: null
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ‘:kotlinCompilerPluginClasspath’.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Cannot resolve external dependency org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.2.60 because no repositories are defined.
Required by:
project :

This doesn’t seem to affect intellij overmuch, but now it is also causing jenkins builds to fail:

  • What went wrong:
    Could not determine the dependencies of task ‘:compileKotlin’.
    Could not resolve all files for configuration ‘:kotlinCompilerClasspath’.
    Cannot resolve external dependency org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.60 because no repositories are defined.
    Required by:
    project :

there is no reason for this dependency to be included, I think, but adding an exclusion does not work, and the build continues to fail. This error disappears after regressing to kotlin 1.2.51. Has a new dependency snuck in during the interim, and why isn’t it resolving via maven central if so?

@nickheitz

See How to set useFallbackCompilerSearch? - #3 by tsvetkov

In short, the dependency should resolve through mavenCentral, but only trough project repository, not buildscript one.

Won’t work:

buildscript {
     repositories {
         mavenCentral()
     }
     dependencies {
          classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60'
     }
}

apply plugin: 'kotlin'

Should work:

buildscript {
     repositories {
         mavenCentral()
     }
     dependencies {
          classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60'
     }
}

apply plugin: 'kotlin'

repositories {
    // this repo should be available in every subproject that uses kotlin
    mavenCentral() // or jcentrer
}
2 Likes