Question

I am converting our build from ant to gradle and have run into a problem when using the ant task wsimport.
This is the original from 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>

This works fine.

From Gradle I made many attempts...

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

Error Property "Type" is already defined - this makes me think the bindings aren't being accepted (at least not both of them) since it worked for 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"
                }
 }

Error Property "Type" is already defined - this makes me think the bindings aren't being accepted (at least not both of them) since it worked for 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"
                )                        
 }

Would not even start. duplicate named parameter 'binding' found

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

Problem: failed to create task or type binding cause: the name is undefined

So basically what I am wondering is... Is there a way to define multiple bindings for wsimport in gradle like there is for wsimport in ant. Thanks.

Was it helpful?

Solution

I figured this out on my own. There turned out to be a different error. This is the way that worked for me.

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

I was also using xjcargs in my wsimport (that I omitted from the original question) and the jars being referenced were named incorrectly. This is what the working task looks like.

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

OTHER TIPS

Yes this works fine for me.

    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")
            }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top