Sync
Sync

Reputation: 3797

How to apply and configure the Kotlin No Arg compiler plugin in Gradle Kotlin DSL?

The documentation only gives an example in Groovy DSL:

plugins {
  id "org.jetbrains.kotlin.plugin.noarg" version "1.3.31"
}

noArg {
    annotation("com.my.Annotation")
}

How does this translate into Kotlin DSL?

Upvotes: 3

Views: 3067

Answers (1)

Sync
Sync

Reputation: 3797

Because Kotlin DSL is statically typed, the syntax will differ slightly from Groovy DSL.

import org.jetbrains.kotlin.noarg.gradle.NoArgExtension

plugins {
    id("org.jetbrains.kotlin.plugin.noarg") version "1.3.31"
}

configure<NoArgExtension> {
    annotation("com.my.Annotation")
}

Differences:

  • Kotlin DSL requires ids in the plugins block to accept an argument of the plugin id.
  • The plugin exposes the type NoArgExtension which is then imported. It's required for the configure block in which the plugin can be configured similar to the Groovy DSL.

Upvotes: 2

Related Questions