Execute Kotlin Scripts with Gradle

Execute Kotlin Scripts with Gradle

Gradle, Kotlin, Software Development, Teaching, Tutorial
Organize Kotlin Scripts as Gradle tasks In this article, you will learn how you can organize multiple Kotlin scripts as Gradle tasks and make them easily executable this way. I've found a discussion about this here. Somebody wanted to execute Kotlin scripts with Gradle build scripts which is, of course, possible by using kotlinc as shown in this (Groovy) build script. This doesn't look very pretty though, and, as described in the corresponding thread, isn't very performant and manageable. Another solution would be to use Gradle scripts written with the Kotlin DSL and define custom tasks within a build.gradle.kts file, which obviously can hold and run Kotlin code naturally: // build.gradle.kts // // Execute Kotlin task with: gradle -q foo task("foo") { group = "com.kotlinexpertise" description = "my foo task"…
Read More
The Power of Gradle Kotlin DSL

The Power of Gradle Kotlin DSL

Functional Programming, Gradle, Kotlin, Software Development, Tutorial
-The following is based on Gradle 4.3.1- A few weeks ago I started migrating most of my Groovy-based gradle.build scripts to Kotlin-backed gradle.build.kts scripts using the Kotlin DSL. Why would I do that? Kotlin is my language of choice and I love the idea of using a single language to do all my work. I never learned programming with Groovy and only know the bloody basics, which always makes me think: "This can't be the best way to do things...". Kotlin, on the other hand, is a language I use on a daily basis and therefore I know how to use the language appropriately. Additionally, Kotlin is a statically-typed language, whereas Groovy isn't. IDEs are having hard times offering code completion and error detection at compile time when a Groovy…
Read More