'wsdl artficats generation using gradle task

I am trying to generate wsdl artifacts using gradle. wsdl java generation fails and i don't see appropriate message either in the debug log or normal build log. Below is my build.gradle file

plugins {
    id 'java'

}

group 'com.example'
version '1.0.0SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


configurations { jaxws }
dependencies { jaxws 'com.sun.xml.ws:jaxws-tools:2.2.6' }

dependencies {
    compile 'com.sun.xml.bind:jaxb-impl:2.2.6'
}


dependencies {
    implementation 'org.springframework:spring-core:5.1.7.RELEASE'
    implementation 'org.springframework:spring-context:5.1.7.RELEASE'
    implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}


task generatewsdlartifacts{


        def rootDir = file("${buildDir}/generated/sources/wsdl")
        def javaDir = file("${rootDir}/java")
        def wsdlJarDir = file("${buildDir}/wsdllib")
        def classesDir = file("${rootDir}/classes")
        def wsdlDir=file("${projectDir}/src/main/resources/wsdl")
        def wsdlFile = file("${wsdlDir}/mywsdl.wsdl")

        doLast{
           // classesDir.mkdirs()
            //javaDir.mkdirs()
            //wsdlJarDir.mkdirs()
            copy {
                from "${wsdlFile}"
                into "${classesDir}"
            }

            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: "${wsdlFile}")
                       wsdl: "${wsdlFile}")
                       {
                            binding(dir:"${wsdlDir}", includes:"jaxb-bindings.xml,jaxws-bindings.xml")
                            xjcarg(value: "-XautoNameResolution")
                        }
            }

            ant.jar(
                    destfile: wsdlJarDir.path + "/mywsdl.jar",
                    basedir: classesDir
            )
        }


}



compileJava.dependsOn generatewsdlartifacts

When i do gradle build below it fails with the below error

Task ::generatewsdlartifacts FAILED

    FAILURE: Build failed with an exception.

    * Where:
    Build file '<path of build file>\build.gradle' line: 56

Need some help here



Solution 1:[1]

On the line wsdlLocation: "${wsdlFile}") you need to remove the end bracket and also need to use = instead of :. (im using idea 2022.1). So it should look like this wsdl= "${wsdlFile}"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BuBaL