1
votes

I'm trying to set up a kotlin project with gradle kotlin DSL as build system in IntelliJ idea,but I'm getting below error when try to run buil.gradle.kts file. I have tried with different kotlin compiler version but no luck.

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

IntelliJ Version:

enter image description here

Gradle version : 6.3

build.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"
}
1
Please provide your main Gradle build file contents, version of intellij you are using, and Gradle version of the project. - Francisco Mateo
What do you mean by "when try to run buil.gradle.kts file"? Can you describe better what you are doing in IJ? - Louis Jacomet
I reproduced it, if "Run" is executed explicitly for the current script (Main menu | Run | Run build.gradle.kts). But that's the wrong way to do it. If you want to build the project, you should execute "Build | Build project" if your build is delegated to Gradle in IDEA settings, or execute one of the build tasks in Gradle tool window: jetbrains.com/help/idea/work-with-gradle-tasks.html - Alexey Belkov

1 Answers

4
votes

The correct way to build a Gradle project in IDEA is to execute "Main menu | Build | Build project" if your build is delegated to Gradle in IDEA settings, or execute one of the build tasks in Gradle tool window: http://jetbrains.com/help/idea/work-with-gradle-tasks.html

However, the behavior you described can be considered a usability problem, I created an issue https://youtrack.jetbrains.com/issue/KT-37814, please follow it for updates.