I want to use workerExecutor.processIsolation to e...
# community-support
p
I want to use workerExecutor.processIsolation to execute some code with a JVM 8, while the Gradle plugin itself should require JVM 21. But I get the error, that the WorkAction is (correctly) compiled with 21, and the JVM 8 can’t run the worker action. Is this a known limitation? I thought it will only call the execute method „somehow“
v
Why do you not simply use a
JavaCompile
task where you set the JVM 8 toolchain?
Or give the compiler
-release 8
so that it produces JVM 8 class files and compiles against the JVM 8 API, then you do not need process isolation either
If you use process isolation with a Java 8 JVM, then of course the code run in that process must be Java 8 compatible, so the actual work action which is executed in that process has to be Java 8 compatible.
p
It is Kotlin code. All the code that will be executed by the workaction is compatible with JVM 8. Only the WorkAction class itself from the Gradle plugin is not compatible.
Oh, I didn’t want to compile the code, but to run the compiled code. The code itself is compiled by the kotlin compiler first.
v
Ah, ok, then maybe just use
javaExec
?
p
Yeah, that was my first idea too but I disliked the main class requirement so I refactored it to processIsolation…
v
I see, well, then you have to make sure that your work action class is compatible to Java 8
p
But I really don’t understand how Gradle calls the work action under the hood and how it passes data at all 🤔 Does gradle rewrite the class during runtime? And what JVM target will it use? 🤔
v
iirc It starts a new process with the JVM you specified or if none, then I think the one Gradle is running with. To that new process is transforms the parameter values and work action class name, instantiates the work action, gives it the parameters, and runs the work action.
So the work action and the work action parameter class should need to be compatible (and any other class it uses)
p
Thank you all. As always, when I have a dependency problem, I created another module that contains the WorkAction class only with JVM 8 target and compileOnly dependencies so it can be added the main Gradle plugin as implementation and all needed runtime dependencies are injected with the worker classpath.
👌 1