【问题标题】:gradle wsimport multiple bindingsgradle wsimport 多个绑定
【发布时间】:2014-02-07 19:30:14
【问题描述】:

我正在将我们的构建从 ant 转换为 gradle,并且在使用 ant 任务 wsimport 时遇到了问题。
这是ant的原文

<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

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

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(dir"${module_src_main_wsdl}", includes:"jaxb-bindings.xml,jaxws-bindings.xml")
                )                        
 }

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

所以基本上我想知道的是......有没有一种方法可以在 gradle 中为 wsimport 定义多个绑定,就像 ant 中的 wsimport 一样。谢谢。

【问题讨论】:

    标签: ant gradle wsimport


    【解决方案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")
                        }
    

    【讨论】:

      【解决方案2】:

      是的,这对我来说很好。

          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")
                  }
          }
      

      【讨论】:

      • 能否解释一下为什么您的解决方案能够提高您贡献的价值?
      猜你喜欢
      • 1970-01-01
      • 2017-06-08
      • 1970-01-01
      • 2019-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多