I am trying to run box tests for my compiler plugi...
# compiler
g
I am trying to run box tests for my compiler plugin (finally!). But the
JvmBoxRunner
does not want to see the plugin's runtime dependency (that is provided by
addJvmClasspathRoots
). My runners configuration can be found here. I am wondering what's going wrong.
d
Runtime jars should be provided separately using
RuntimeClasspathProvider
. See the example in kotlinx.serialization tests.
y
I fixed this recently in the compiler plugin template. Here's what it looks like now!
Copy code
private val annotationsRuntimeClasspath = TODO()

fun TestConfigurationBuilder.configureAnnotations() {
    useConfigurators(::PluginAnnotationsProvider)
    useCustomRuntimeClasspathProviders(::PluginAnnotationsClasspathProvider)
}

private class PluginAnnotationsProvider(testServices: TestServices) : EnvironmentConfigurator(testServices) {
    override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) {
        configuration.addJvmClasspathRoots(annotationsRuntimeClasspath)
    }
}

private class PluginAnnotationsClasspathProvider(testServices: TestServices) : RuntimeClasspathProvider(testServices) {
    override fun runtimeClassPaths(module: TestModule) = annotationsRuntimeClasspath
}
👍 1
g
Thanks! Now it works! But at first, I thought I have to replace
EnvironmentConfigurator
with
RuntimeClasspathProvider
instead of leaving the first one intact 🙂 Thank you for the examples!