In my plugin I need to execute static bootstrapping method from an external JAR to perform an analysis. Currently I call it directly from code with MutationCoverageReport.main(arg)
, but this forces me to create a compile time dependency in my plugin which is hard to modify (choose a different JAR version) when executing the plugin.
I would like to call it using reflection and found some examples in Gradle code like WorkerProcessBuilder
or JavaExecHandleBuilder
. Nevertheless they are in org.gradle.process.internal
package and I'm not sure if it is recommended to use it from the external plugin.
Question. What is the recommended way for Gradle plugin to run arbitrary Java method from external class with specified classpath?
Btw, I would prefer to not use an Ant
task as it is a separate project and another layer of abstraction with its potential bugs and limitations.