无法在Intellij idea中使用gradle kotlin DSL构建kotlin文件

Ven*_*cat 11 intellij-idea gradle kotlin

我正在尝试使用 gradle kotlin DSL 作为 IntelliJ idea 中的构建系统来设置 kotlin 项目,但在尝试运行 buil.gradle.kts 文件时出现以下错误。我尝试过不同的 kotlin 编译器版本,但没有成功。

warning: default scripting plugin is disabled: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
error: unable to evaluate script, no scripting plugin loaded
Run Code Online (Sandbox Code Playgroud)

IntelliJ 版本:

在此输入图像描述

摇篮版本:6.3

构建.gradle.kts

plugins {
    id("org.jetbrains.kotlin.jvm") version "1.3.70"

    // Apply the application plugin to add support for building a CLI application.
    application
}

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // Align versions of all Kotlin components
    implementation(platform("org.jetbrains.kotlin:kotlin-bom"))

    // Use the Kotlin JDK 8 standard library.
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

application {
    // Define the main class for the application.
    mainClassName = "Music.AppKt"
}
Run Code Online (Sandbox Code Playgroud)

Ale*_*kov 12

在 IDEA 中构建 Gradle 项目的正确方法是,如果您的构建在 IDEA 设置中委托给 Gradle,则执行“主菜单 | 构建 | 构建项目”,或者在 Gradle 工具窗口中执行构建任务之一:http://jetbrains .com/help/idea/work-with-gradle-tasks.html

但是,您描述的行为可以被视为可用性问题,我创建了一个问题https://youtrack.jetbrains.com/issue/KT-37814,请关注它以获取更新。