问题
I've implemented a Groovy wrapper around some code to instantiate that code as a Gradle (6.2.2) Task:
task xprocTest(type: XMLCalabashTask) {
input("source", "../src/test/resources/source.xml")
output("result", "/tmp/x/result.xml")
pipeline "pipe.xpl"
}
The underlying code searches the classpath for classes with a particular annotation. That works fine and finds about 97 classes so annotated.
I'm trying to implement a wrapper (in Java this time, if that's relevant) around the same code to instantiate that code as a Copy filter (extending BaseParamFilterReader
):
task filterTest(type: Copy) {
into "/tmp/x/a"
from "../src/test"
include "**/*.xml"
filter(XMLCalabashFilter, pipeline:"pipe.xpl")
}
In this context, when the code runs, it finds nothing on the classpath.
I'm assuming this has something to do with the class loader or other configuration in Gradle. The jar file containing the classes is clearly on the class path because it runs the code that attempts to search for annotations. It just doesn't find any.
Is this a surmountable problem?
来源:https://stackoverflow.com/questions/60898982/how-does-the-gradle-runtime-configuration-for-a-task-differ-from-the-configurati