https://kotlinlang.org logo
#gradle
Title
# gradle
a

Arjan van Wieringen

03/16/2024, 6:16 PM
I am developing a Gradle plugin according to the documentation. Am I correct that we can't (or won't) use the Kotlin JVM plugin for writing plugins? But it is as follows?
Copy code
plugins {
    `java-gradle-plugin`
    `kotlin-dsl`
}

sourceSets {
    main {
        kotlin {
            srcDir("src/main/kotlin")
        }
    }
}
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:custom_plugins_standalone_project EDIT: well.... actually that just works, after removing
kotlin-dsl
. I am a bit uncertain whether or not kotlin-dsl was needed. I suppose it wasnt. A plugin is 'just' another project.
h

hfhbd

03/16/2024, 6:24 PM
You don’t need the first plugin too. The sourceSet is also not needed. But the kotlin-dsl plugin adds the SAM plugin.
a

Arjan van Wieringen

03/16/2024, 6:42 PM
Yeah I removed it. I need the first one for:
Copy code
gradlePlugin {
    plugins {
        create("wiredPlugin") {
            id = "nl.helicotech.wired.plugin"
            implementationClass = "nl.helicotech.wired.plugin.WiredPlugin"
        }
    }
}
v

Vampire

03/16/2024, 7:16 PM
kotlin-dsl
applies
java-gradle-plugin
,
kotlin-dsl.base
, and
kotlin-dsl.precompiled-script-plugins
plugins
kotlin-dsl.base
plugin applies
embedded-kotlin
, adds
gradleKotlinDsl()
to the dependencies of
compileOnly
and
testImplementation
configurations, and configures the Kotlin DSL compiler plugins for example for proper SAM conversion for
Action
and similar.
👍 3