clone the gradle-script-kotlin project
copy/paste from the cloned project to your project:
update the content of the
build.gradle.kts based on your needs, you can use as inspiration the scripts in the project just cloned or in one of its samples
now open Intellij and open your project, in the explorer window, it should be recognized as a Gradle project, if not, expand it first.
after opening, let Intellij works, open
build.gradle.kts and check if there are any error. If the highlighting is not working and/or is everything marked red, then close and reopen Intellij
open the Gradle window and refresh it
OSX and Ubuntu work out of the box.
Small bonus, if you want to avoid all the hassle of publicing on Maven and similar, use Jitpack, the lines to add are almost identical compared to Groovy. You can take inspiration from this project of mine.