gradle wsimport多个绑定

时间:2014-02-07 19:30:15

标签: ant gradle wsimport

我正在将构建从ant转换为gradle并在使用ant任务wsimport时遇到问题。
这是蚂蚁的原作

<wsimport sourcedestdir="${module.local-lib.dir}"
                          destdir="${module.local-lib.dir}"
                          wsdl="${common.wsdl.dir}/${wsdl.file.name}"
                          xadditionalHeaders="true"
                          fork="true">
                    <binding dir="${wsdl.dir}" includes="jaxb-bindings.xml,jaxws-bindings.xml"/>                        
                </wsimport>

这很好用。

从Gradle我做了很多尝试......

    ant{
                    taskdef(name:'wsimport', classname:'com.sun.tools.ws.ant.WsImport', classpath:configurations.tools.asPath)
                    wsimport(
                            keep:true,
                            destdir: tempDestFile,
                            wsdl:"${common_WSDL_dir}/${current_wsdl_name}.wsdl",
                            xadditionalHeaders:true
                    ){
                        binding(dir:file("${module_src_main_wsdl}"), includes:"${jaxws_consumed_binding}")
                    }
     }

错误属性“类型”已经定义 - 这使我认为绑定不被接受(至少不是两者都被接受),因为它适用于蚂蚁

ant{
                taskdef(name:'wsimport', classname:'com.sun.tools.ws.ant.WsImport', classpath:configurations.tools.asPath)
                wsimport(
                        keep:true,
                        destdir: tempDestFile,
                        wsdl:"${common_WSDL_dir}/${current_wsdl_name}.wsdl",
                        xadditionalHeaders:true
                ){
                    binding="${module_src_main_wsdl}/jaxb-bindings.xml"
                    binding="${module_src_main_wsdl}/jaxws-bindings.xml"
                }
 }

错误属性“类型”已经定义 - 这使我认为绑定不被接受(至少不是两者都被接受),因为它适用于蚂蚁

ant{
                taskdef(name:'wsimport', classname:'com.sun.tools.ws.ant.WsImport', classpath:configurations.tools.asPath)
                wsimport(
                        keep:true,
                        destdir: tempDestFile,
                        wsdl:"${common_WSDL_dir}/${current_wsdl_name}.wsdl",
                        xadditionalHeaders:true,
                        binding:"${module_src_main_wsdl}/jaxb-bindings.xml",
                        binding:"${module_src_main_wsdl}/jaxws-bindings.xml"
                )                        
 }

甚至不会开始。找到重复的命名参数'binding'

ant{
                taskdef(name:'wsimport', classname:'com.sun.tools.ws.ant.WsImport', classpath:configurations.tools.asPath)
                wsimport(
                        keep:true,
                        destdir: tempDestFile,
                        wsdl:"${common_WSDL_dir}/${current_wsdl_name}.wsdl",
                        xadditionalHeaders:true,
                        binding(dir"${module_src_main_wsdl}", includes:"jaxb-bindings.xml,jaxws-bindings.xml")
                )                        
 }

问题:无法创建任务或类型绑定 原因:名称未定义

基本上我想知道的是...有没有办法在gradle中为wsimport定义多个绑定,就像在ant中使用wsimport一样。谢谢。

2 个答案:

答案 0 :(得分:1)

我自己想出来了。结果证明是一个不同的错误。这是对我有用的方式。

ant
    {
                        taskdef(name:'wsimport', classname:'com.sun.tools.ws.ant.WsImport', classpath:configurations.tools.asPath)
                        wsimport(
                                keep:true,
                                destdir: tempDestFile,
                                wsdl:"${common_WSDL_dir}/${current_wsdl_name}.wsdl",
                                xadditionalHeaders:true
                        ){
                            binding(dir:file("${module_src_main_wsdl}"), includes:"jaxb-bindings.xml,jaxws-bindings.xml")
                        }
     }

我也在我的wsimport中使用了xjcargs(我在原始问题中省略了)并且被引用的jar被错误地命名。这就是工作任务的样子。

 wsimport(
                            keep:true,
                            destdir: tempDestFile,
                            wsdl:"${f.absolutePath}",
                            xadditionalHeaders:true
                    ){
                        binding(dir:"${common_WSDL_dir}", includes:"common-jaxb-bindings.xml,common-jaxws-bindings.xml")
                        xjcarg(value:configurations.compile.asPath + "/schemas-common.jar")
                        xjcarg(value:configurations.compile.asPath + "/compile/schemas-hrxml3_1.jar")
                    }

答案 1 :(得分:0)

是的,这对我来说很好。

    ant {
            taskdef(name: 'wsimport',
                    classname: 'com.sun.tools.ws.ant.WsImport',
                    classpath: configurations.jaxws.asPath)
            wsimport(keep: true,
                    destdir: classesDir,
                    sourcedestdir: javaDir,
                    extension: "true",
                    verbose: "true",
                    quiet: "false",
                    xnocompile: "false",
                    xendorsed: true,
                    wsdlLocation: "OrderImportService.wsdl",
                    wsdl: "${wsdlFile}") 
            {
                binding(dir:"${wsdlDir}", includes:"jaxb-bindings.xml,jaxws-bindings.xml")
                xjcarg(value: "-XautoNameResolution")
            }
    }