Gradle无法解析“ kotlin”插件。我是否缺少正确的Maven存储库?

时间:2018-12-10 21:24:52

标签: gradle kotlin build.gradle gradle-plugin

gradle tasks无法告诉我找不到插件'kotlin'。我的build.gradle文件开头为:

buildscript {
  ext.kotlin_version = '1.3.11'
  repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url "https://dl.bintray.com/kotlin/kotlin-dev/" }
    maven { url "http://central.maven.org/maven2/" }
  }
  dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  }
}

plugins {
  id 'kotlin'
  id 'application'
}

WRT Maven存储库,我显然只是想多余地添加我能找到的所有厨房水槽。我没有尝试过,并评论了一些。我想念哪一个? 从日志中:

12:55:04.419 [DEBUG] [org.gradle.launcher.daemon.server.exec.ReturnResult] Daemon is dispatching the build result: Failure[value=org.gradle.initialization.Repor
tedException: org.gradle.internal.exceptions.LocationAwareException: Build file '/home/_/workspace/_/build.gradle' line: 18
Plugin [id: 'kotlin'] was not found in any of the following sources:

- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/5.0/userguide/standard_plugins.html for available core plugins)
- Plugin Repositories (plugin dependency must include a version number for this source)]

我还尝试了1.3.10版,因为它与gradle版本信息中列出的内容匹配:

------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------

Build time:   2018-11-26 11:48:43 UTC
Revision:     7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Linux 4.19.6-200.fc28.x86_64 amd64

1 个答案:

答案 0 :(得分:1)

Kotlin 不是核心插件,因此您必须包括该版本。使用plugins配置时,名称也不同:

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.11"
}

如果使用apply函数,仍可以使用简单名称:

apply plugin: "kotlin"

您将在Targeting the JVM上找到此信息。