如何超越gradle wsimport任务JDK 8访问限制? [英] How to surpass gradle wsimport task JDK 8 access restrictions?
问题描述
我在我的gradle构建中有一个wsimport任务,工作正常,直到Java 7:
任务wsimport {
ext .destDir = file($ {buildDir} / generated / java)
ext.wsdlSrc = file(src / main / resources / schema / example / my.wsdl)
ext.bindingSrc =文件(src / main / resources / schema / example / bindings.xsd)
outputs.dir destDir
doLast {
ant {
destDir.mkdirs()
taskdef(名称:'wsimport',
classname:'com.sun.tools.ws.ant.WsImport',
classpath:configurations.jaxws.asPath)
wsimport(keep:true ,
包:'net.example.my',
xnocompile:true,
quiet:true,
sourcedestdir:destDir,
wsdl:wsdlSrc,
绑定:bindingSrc,
编码:UTF-8
)
}
}
}
切换到JDK 8(内部版本1.8.0-b129)时,出现以下错误:
java.lang.AssertionError:org.xml.sax.SAXParseException; systemId:... schema_reference:
由于accessExternalSchema属性设置的限制,不允许文件访问,因此无法读取模式文档'xjc.xsd'。
寻找问题我发现了下面的帖子(令人惊讶地说明了Java 7的问题):< a href =https://github.com/stianh/gradle-jaxb-plugin/issues/20> https://github.com/stianh/gradle-jaxb-plugin/issues/20
但是我无法将环境/参数传递给wsimport / xjc。
如何禁用此访问或限制?
<解决方案我发现的唯一工作解决方案是使用反射设置系统属性:
code> task wsimport {
System.setProperty('javax.xml.accessExternalSchema','file')
...
}
使用 ext
或 systemProperty
不适合我。
我安装了gradle 1.11。
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?
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.
这篇关于如何超越gradle wsimport任务JDK 8访问限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!