gradle wsimport [英] gradle wsimport
本文介绍了gradle wsimport的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从命令行运行wsimport,以从WSDL生成Java类,如下所示.
I'm running wsimport from my commandline to generate java classes from WSDL as below.
wsimport -J-Djavax.xml.accessExternalDTD=all
-J-D-Djavax.xml.accessExternalSchema=all
-b http://www.w3.org/2001/XMLSchema.xsd
-b customization.xjb
-s genSrc https://example.com/XYZ.asmx?wsdl
我想创建等效的gradle任务.由于公司的限制,我不应该使用任何随机的自定义gradle插件.最好的方法是什么?
I want to create the equivalent gradle task. I shouldn't be using any random custom gradle plugins due to company restrictions. What's the best way to go about it?
推荐答案
正如@lunicon所述,您应该使用ant任务,这是一些改进,因为gradle更改了一些属性.
As @lunicon mention, you should use an ant task, here are some improvements since gradle has change a couple of properties.
configurations {
jaxws
}
dependencies {
jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4'
}
task wsimport {
ext.destDir = file("${projectDir}/src/main/generated")
doLast {
ant {
sourceSets.main.output.classesDirs.inits()
destDir.mkdirs()
taskdef(name: 'wsimport',
classname: 'com.sun.tools.ws.ant.WsImport',
classpath: configurations.jaxws.asPath
)
wsimport(keep: true,
sourcedestdir: 'src/main/java',
package: "com.example.client.api",
wsdl: 'src/main/resources/api.wsdl') {
xjcarg(value: "-XautoNameResolution")
}
}
}
}
compileJava {
dependsOn wsimport
source wsimport.destDir
}
这篇关于gradle wsimport的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文