Another question on compiler plugins development u...
# kotlin-toolchain
g
Another question on compiler plugins development using Kotlin Toolchain. I am trying to migrate compiler plugin test logic to Kotlin Toolchain. And the problem is that there is the following snippet of Gradle configuration
Copy code
tasks.named<Test>("test") {
    useJUnitPlatform()

    doFirst {
        val testRuntimeClasspathFiles = project
            .configurations
            .getByName("testRuntimeClasspath")
            .files

        fun setLibraryProperty(propName: String, jarName: String) {
            val path = testRuntimeClasspathFiles
                .find { """$jarName-\d.*jar""".toRegex().matches(it.name) }
                ?.absolutePath
                ?: return
            systemProperty(propName, path)
        }

        setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib", "kotlin-stdlib")
        setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8")
        setLibraryProperty("org.jetbrains.kotlin.test.kotlin-reflect", "kotlin-reflect")
        setLibraryProperty("org.jetbrains.kotlin.test.kotlin-test", "kotlin-test")
        setLibraryProperty("org.jetbrains.kotlin.test.kotlin-script-runtime", "kotlin-script-runtime")
        setLibraryProperty("org.jetbrains.kotlin.test.kotlin-annotations-jvm", "kotlin-annotations-jvm")
    }
}
and I am stuck migrating dependencies finding via
testRuntimeClasspathFiles
(that is a list of files from test runtime classpath that Gradle resolved). Because there is no such logic in Kotlin Toolchain. So the question is "What would you do?" Would you file a ticket about classpath access (from Kotlin Toolchain plugin, possibly)? Or would you file a ticket to create compiler-plugin-oriented logic hardcoded into Kotlin Toolchain like it is made for CMP, Ktor, etc.?
Very similar code is placed in official Kotlin compiler template: github.com/Kotlin/compiler-plugin-template/blob/…/build.gradle.kts However, there is a branch
devkit
in the repository that uses some unknown to me Gradle plugin that is published on packages.jetbrains.team So I don't know if the Gradle-based story (about compiler plugin tooling setup) will be changed in the future...
j
FWIW, we have an open issue already to support
testRuntimeClasspath
for plugins: KTC-5780
You would also need your plugin to be able to set test system properties as well, though. And at the moment plugins can't contribute data to
module.yaml
(this is also planned, but not there yet)
g
Got it. Thanks!