Setting up init.gradle.kts for custom gradle distribution


We’re working on setting up a custom gradle distribution at our company, to help simplify adoption. We use the Kotlin DSL by preference (since we’re becoming Kotlin-first) and one of the incentives for moving to gradle is that it allows us to use Kotlin in their builds as well.

Main problem, though, is that there is still a large lack of examples - especially once one starts working with more obscure issues, where the Kotlin DSL is far less intuitive and obvious than groovy’s. And unfortunately, the documentation is no help at all.

For instance, we’d like to add a default init.gradle.kts script to the custom gradle distribution that adds the kotlin-bom and kotlin-stdlib-jdk8 as dependencies to every project, since all projects will generally do that. But just ading dependencies to an allprojects {} block doesn’t seem to work. Similar with adding and configuring plugins. Two basic operations, but no documentation of how to do them that I can find.

Anyone can point to some good tutorials/docs or alternative examples using the Kotlin DSL?

Found this to be a competely intractable problem - there doesn’t seem to be any good way (at least not any way which is properly documented) to write a really useful init.gradle.kts script that is useful for this purpose.

So at the end of the day, we had to fall back to an old-fashioned init.gradle, and were able to build a custom gradle distribution that fulfilled our purposes (which is - basically - to reduce the build.gradle.kts of most projects to just a few variables and the list of dependencies.

If anyone else is struggling with similar problems, our repo for the project may be of some help. See: