gradle - 由于缺少依赖项,Kotlin buildSrc 在 Gradle 4.10 上失败

标签 gradle kotlin gradle-kotlin-dsl

升级到 Gradle 4.10 时,我在尝试编译时遇到以下错误:

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

请注意,我在 Gradle 编译过程中使用了 buildSrc

最佳答案

这是由于 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() }

关于gradle - 由于缺少依赖项,Kotlin buildSrc 在 Gradle 4.10 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52062475/

相关文章:

android - 错误:找不到符号类Android Studio

android - 如何使用 Android Studio 和 Gradle 创建最佳的 Android 应用项目结构?

android - Sonar Android Lint 未找到匹配问题

spring - 无法将 'java.lang.String' 类型的属性值转换为 thymeleaf 形式的属性 'java.time.LocalDate' 所需的类型 'date'

gradle - 如何从 Gradle 中的 Kotlin 获取 Groovy DSL 提供的值

gradle - 是否可以将 Gradle 脚本作为插件打包到 Jar 中

java - 从 url 获取简单的 Json 字符串并将其转换为 String[] Android

android - 如何在调用 Video.createBackgroundSubtractorMOG2() 时修复 UnsatisfiedLinkError?

gradle - 如何在 Gradle 中延迟获取主要 sourceSets

android - Unresolved reference : android build failed with kotlin dsl (reproducible in an empty project)