How to use java toolchain in a plugin?

My plugin is activated before build and generates extra binary .class files (for jpa weaving) and it’s required that the specified in the build.gradle toolchain were used to generate them. In other words I need that my plugin run under a particular java toolchain, not the one that is used to run gradle.
Now gradle supports java toolchains but I still don’t realize to use it for my case.
Any ideas?