Possible to use gradle toolchain for kotlin runtime?


gradle has introduced toolchains for jvm projects. I could not find any docs on how to use this with kotlin though.

Specifically, my understanding is that in the gradle build config, I can define what the jvm target, source etc are. I can also say (via kotlin plugin) not to use the jdk by default (nojdk). What I cannot say – as far as I understand – is what java version to use at runtime (eg. when running tests). It just uses the one I have installed on my system (I think it would be possible to hard-code a path to the jdk, but that’s not really an option).

So would it also be possible for the kotlin gradle plugin to use the defined java toolchain at runtime?

Thanks for any hints :slight_smile:

  • Reto

I ran into this problem myself recently, here’s what I did to solve the problem.

See https://stackoverflow.com/a/65543854/713809

Best regards,