13

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" } 
3
  • Please provide your main Gradle build file contents, version of intellij you are using, and Gradle version of the project. Commented Mar 26, 2020 at 1:32
  • 1
    What do you mean by "when try to run buil.gradle.kts file"? Can you describe better what you are doing in IJ? Commented Mar 26, 2020 at 18:21
  • 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 Commented Mar 27, 2020 at 8:34

2 Answers 2

13

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, I wasted a TON of time on this. stackoverflow.com/questions/60940476/… . I must say that my experience has been that if I run into bugs within 1 hour of using some tool, that tool is likely garbage. It soured me on using Intellij / Kotlin. Might choose python instead.
9

To add an answer that could also work for some cases. After modifying the build.gradle, don't press the triangular run button while viewing the gradle file. Move to one of the kotlin/java files and run from there

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
Oh, man, you saved me from insanity, after I read your comment I noticed that the run configuration has "Current file" and yes, I was pressing Run button and it was trying to run gradle file instead of my main, created a run config and it started working!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.