Slackbot
05/14/2022, 4:42 PMThomas Broyer
05/14/2022, 4:47 PMafterEvaluate . Alternatively, don't use a property but a method: when the method is called is when you actually configure the gradlePlugin {}.Martin
05/14/2022, 4:48 PMMartin
05/14/2022, 4:48 PMafterEvaluate{} ...Martin
05/14/2022, 4:48 PMCristianGM
05/14/2022, 5:07 PMAndrew Lethbridge
05/14/2022, 6:03 PMAndrew Lethbridge
05/14/2022, 6:15 PMMartin
05/14/2022, 6:18 PMMartin
05/14/2022, 6:18 PMgradlePlugin{}Andrew Lethbridge
05/14/2022, 6:20 PMAndrew Lethbridge
05/14/2022, 6:22 PMMartin
05/14/2022, 6:23 PMAndrew Lethbridge
05/14/2022, 6:29 PMMartin
05/15/2022, 2:51 PMPublishingOption above) captures the current context and becomes an inner class so you have to pass "this" when creating it:
val extension = extensions.create("myPublishing", PublishingOptions::class, this)Martin
05/15/2022, 2:53 PMkotlin-dsl plugin. That's a lot of trouble and extra compilation time to get a little bit of typesafe accessorsThomas Broyer
05/15/2022, 3:09 PMPublishingOptions class into its own .kt file. Not only will it be a true top-level class so you don't need that this argument, you can also control its actual name which makes it much easier to import from other projects (other plugins building on top of yours, or just projects that want to factor some things with helper methods or whatever)Martin
05/15/2022, 3:10 PMMartin
05/15/2022, 3:11 PM.kt I think :)Martin
05/15/2022, 3:12 PMCristianGM
05/15/2022, 6:54 PMMartin
05/15/2022, 8:23 PMbuild-logic/build.gradle.kts
plugins {
`embedded-kotlin`
}
apply(plugin = "kotlin-sam-with-receiver")
extensions.findByType(SamWithReceiverExtension::class.java)
.annotation(HasImplicitReceiver::class.java.name)
I'm pretty happy with it, it has a good chunk of the "DSL" parts so that copy pasting "mostly" works (except for top level extensions and configurations)
And it's close enough to "regularโ Kotlin that I don't feel there's too much magic going on.
Also allows me to use Kotlin 1.5 and saves "some" accessor generation so I'm hoping it's a bit fasterMartin
05/15/2022, 8:24 PM