wsdl2java
wsdl2java copied to clipboard
wsdl2java section is run every time for every task
My wsdl2java{}
definition:
wsdl2java {
generatedWsdlDir = file("$projectDir/src/generated")
wsdlDir = file("$projectDir/src/resources/wsdl")
wsdlsToGenerate = getWsdlDefinitions()
}
As you can see the wsdlsToGenerate
is built dynamically by other function (the code is simplified a lot):
def getWsdlDefinitions() {
println "Adding WSDL definitions."
def wsdlDefinitions = []
wsdlDefinitions.addAll(wsdl2javadir("xxx"))
wsdlDefinitions.addAll(wsdl2javadir("yyy"))
return wsdlDefinitions
}
The contents of wsdl2javadir()
function are not important here. The above solution causes the println
output each time I run any of the Gradle tasks (even other than wsdl2java
) which implies that this wsdl2java {}
section is run every time for every Gradle task.
Is there a way of defining this configuration without causing this issue?
That's how Gradle works; your method gets evaluated as part of the configuration phase.
You could try to put it in a closure instead:
wsdl2java {
wsdlsToGenerate = { getWsdlDefinitions() }
}
That might work. If not, the task needs to be changed to support this, I guess.