Using the latest Gradle and .kts build scripts, ho...
# gradle
k
Using the latest Gradle and .kts build scripts, how can I specify compiler options for a custom sourceSet? For example, for main and test sourceSets it's:
Copy code
tasks {
    compileKotlin {
        kotlinOptions { ... }
    }
    compileTestKotlin {
        kotlinOptions {... }
    }
}
How would I specify options for some other buildSrc, let's call it "someOtherSrc"?
b
Don't think you can, seeing as custom sourceSets are virtual and don't have a direct kotlin target.
But have a look at your task graph. Kotlin plugin might be generating separate compile tasks, in which case you can access them via this:
Copy code
tasks.named<KotlinCompile>("compileMyCustomSourceSetKotlin") { ... }
k
Thanks, it seems to be working! My custom sourceSets are for kotlinx.benchmark benchmarks, and there was a problem that benchmark code by default sing JVM 1.8 and my code uses JVM 16 as a target. Mixing of those two was problematic, now it looks like it's working...
b
Wow, I certainly did not expect this to work 😀
😁 1
Btw, in the future always specify which kotlin plugin you're using for such questions - jvm, js or mpp
k
Sure thing! I'm not sure it's 100% working, there are still some kotlinx.benchmark errors... but at least I'm not getting the mismatched JVM version error
In the end, everything works perfectly! Thanks once again 😉
🎉 1