问题
I have a wsimport task in my gradle build working fine until Java 7:
task wsimport {
ext.destDir = file("${buildDir}/generated/java")
ext.wsdlSrc = file("src/main/resources/schema/example/my.wsdl")
ext.bindingSrc = file("src/main/resources/schema/example/bindings.xsd")
outputs.dir destDir
doLast {
ant {
destDir.mkdirs()
taskdef(name: 'wsimport',
classname: 'com.sun.tools.ws.ant.WsImport',
classpath: configurations.jaxws.asPath)
wsimport(keep: true,
package: 'net.example.my',
xnocompile: true,
quiet: true,
sourcedestdir: destDir,
wsdl: wsdlSrc,
binding: bindingSrc,
encoding: "UTF-8"
)
}
}
}
When switching to JDK 8 (build 1.8.0-b129) I get the following error:
java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: ... schema_reference:
Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
Searching for the problem I found the following post (describing the problem also with Java 7 surprisingly): https://github.com/stianh/gradle-jaxb-plugin/issues/20 But I am unable to pass the environment/argument to wsimport/xjc.
How to disable this access or the restriction?
回答1:
The only working solution I found was to set a system property using reflection:
task wsimport {
System.setProperty('javax.xml.accessExternalSchema', 'file')
...
}
All other solutions using ext
or systemProperty
did not work for me.
I have gradle 1.11 installed.
来源:https://stackoverflow.com/questions/22044397/how-to-surpass-gradle-wsimport-task-jdk-8-access-restrictions