I currently using intellij v2017.2.5 community edition. The editor does not recognize kotlin DSL syntax in the build.gradle.kts. E.g editor flagged out errors such as unresolved reference plugin when I use the plugin function, such as shown below
Great thanks for your reply. I place your sample code, still the intellij editor displays unresolved reference: plugins error (among all other syntax errors) .
Maybe syntax is correct, but the editor is not configured to recognize it. Hence Is there something i need to do to configure for the intellij editor?
*Note that I did not execute using gradlew, cause I prefer using the local distribution of the gradle (which I download from gradle official website), unless executing the gradlew can help intellij editor to recognize the kotlin dsl.
I just recently started to play a bit with the gradle kotlin DSL and I created a project poi DSL.
You can clone it locally and see if this works for you. https://github.com/jtonic/dsl-poi
For me it works w/o any issues with IntelliJ Idea 2017.2.5 (2017.3 EAP) and latest version of kotlin stdlib and idea plugin (1.1.51). Gradle version: 4.2.1.
I did another try.
On my system I had install gradle version 3.4.1 (configured with GRADLE_HOME).
When I ran the gradle script with it, it failed. Moreover when the gradle wrapper was quite old the gradle.build.kts was full of red lines, and running the application lead to an error.
As soon as I updated the gradle on my machine to latest 4.2.1 all is fine in Idea, gradlew and gradle.
The version of gradle is extremely important. Try to use the latest one. Moreover I remembered I read somewhere that gradle v 4.0 have the issue you are currently facing.
I suppose you use the IntelliJ Idea 2016.1.x or recent.
Note: Even it is an warning I personally took it very seriously. Quite ofter idea warns the version of its kotlin plugin and project one (configured in gradle or maven) is not the same.
I noticed the latest kotlin dsl gradle DSL (built in the latest gradle - 4.2.1) comes with kotlin 1.1.50.
In my project on the github the gradle.build.kts based one is 1.1.51. Modify it to 1.1.50 and the warn should vanish.
Thanks for your reply and assistance!
Currently, I am already using the below
Intellij IDEA 2017.25
Intellij Idea kotlin plugin (1.1.51-release-IJ2017.2-1)
Gradle 4.2.1
kolin version in gradle.build.kts? I not sure what this mean. I did not configure anything for this.
Note: I configure Intellij to use my local distribution of gradle 4.2.1, and I did not use gradle wrapper at all.
I have reduced the content of my gradle.build.kts to only 3 lines as shown below
plugins{
java
}
but still the plugins and java words are in red, meaning unrecognized. Not sure why
Extra Info: My application source codes is actually java source code, not kotlin source codes.
It is strange. I use the same versions as you and for me it works.
I created a new gradle kotlin dsl project with the gradle 4.2.1 install on my system, and this project also works like a charm. the command i ran was
I am glad it works for you in the end.
I am sure Jetbrains Dev Team will improve the support of kotlin based (build.gradle.kts) gradle project.
For me build.gradle.kts is better than the vanilla gradle.build in terms that it is type safe - this leads to a better IDE support.
Of course Gradle Kotlin DSL (GitHub - gradle/kotlin-dsl-samples: Samples builds using the Gradle Kotlin DSL) is a new project, so it expected to have some rough edges. But surely they will be addressed by the kt/gradle teams and community .
I am seeing this error too. Here are my steps for reproduction:
Create new project
Select Gradle (Kotlin DSL)
Uncheck Java
Check Kotlin (Java)
Fill out the artifact/group/version stuff
Use all default options
Click create
Double click build.gradle.kts to view the file
Tons of red text appears in the file
I ran “check for updates” in IntelliJ before doing this. Ubuntu 16.04 LTS
Using the currently stable versions (IntelliJ IDEA 2017.3.4, Gradle 4.5.1 and Kotlin 1.2.21) on Windows 10, I was able to resolve it by following these steps:
Exit IDEA.
If needed, update the Gradle wrapper. Repeat the following command until Gradle says it is up to date: ./gradlew wrapper