Kotlin-Scripting with Gradle dependencies

I learned that I can have a Kotlin-Script script.main.kts that declares dependencies like this:


import java.io.File
import org.apache.pdfbox.Loader
import org.apache.pdfbox.pdmodel.PDDocument

val pdfFile = File("example_041.pdf")

and run it like this
kotlin script.main.kts

Now how would the minimal build.gradle.kts look like, that would allow me to manage dependencies using Gradle.

Do I really need five Gradle plugins, a source folder, and a “script base class”, and a “scripting host” class that I need to implement? If so, I’d consider this far beyong the realm of “scripting”.

I guess I would be fine with managing all transitive dependencies using @file:DependsOn instead, but I was under the impression that I could simply use Gradle for this specific aspect.