Kotlin DSL in under an hour
summary
Builds a working Kotlin internal DSL from Java library classes using concrete steps: convert Java to Kotlin, add extension functions and properties, replace Consumer with functional types and lambdas with receiver, use apply and inline helpers, and expose infix helpers for nicer literals. Implements nested-block syntax (client { twitter { handle "x" } company { name "y" } }) that compiles and runs, then prevents accidental receiver clashes by extending types and adding a DSL marker annotation so the DSL is reusable and type-safe.
AI-written summary · about
chapters (16)
- 0:00Start
- 3:57give you a few examples of existing dsl
- 4:51define the layout of your android app
- 8:09transform an existing java code
- 11:12string interpolation with this expression syntax inside the strings
- 13:08creating the extension in coupling code for the client class
- 16:33the nested blocks
- 18:15define a block as a consumer interface
- 19:32create the anonymous implementation of that interface
- 20:34convert the interface to lambda
- 21:10remove the consumer interface
- 22:15creating the nested blocks
- 23:55an extension lambda
- 33:00using a dsl marker annotation
- 37:44adding the extension method to the integer
- 37:55add an extension








