Kotlin-maven-plugin doesn't pick up source roots added by other plugins?

TL;DR: source roots added using MavenProject.addCompileSourceRoot don’t seem to be picked up by the kotlin-maven-plugin.

We wrote our own plugin that generates Kotlin sources that are written to target/generated-sources/foobar. Our plugin uses MavenProject.addCompileSourceRoot to make the overall build aware that this directory should be included as an additional source root.

However, kotlin-maven-plugin doesn’t seem to pick up additional source roots added in this way.

So we have to manually specify the additional root like so:


Is there anything we can do to make the Kotlin Maven plugin aware of our additional source root so that users of our plugin don’t have to always add in this boilerplate?

Hi! As I see, there is an outstanding issue about this: https://youtrack.jetbrains.com/issue/KT-13995. It’s not very detailed, but I think it’s describing the same problem. Please feel free to add your use case and workaround there.

Thanks for the response @Alexey.Belkov - I hadn’t noticed that ticket - it seems to exactly cover our situation.

I’ve added more detail to the ticket as you suggested. Apologies for not coming up with a completely reproducible example.

1 Like