Wsdl2java failing with "The Command line is too long." error on Windows 10

Hi, I am trying to build a Gradle project (Spring Boot) on Windows 10 and ended up failed with “The Command line is too long.” error. Please assist.

build.gradle looks like below

def webservices =[
[wsdl: ‘AWDService.wsdl’],
[wsdl: ‘ImageService.wsdl’],
]

webservices.each { webservice →
task “wsdl2java${webservice.wsdl}”(type: Exec) {
commandLine getCommandListForOS(“${wfpHome}/bin/WSDL2Java”) +
packageNames +
[‘-role’, ‘server’,
‘-container’, ‘web’,
‘-classpath’, configurations.runtime.asPath,
‘-output’, “${buildDir}/generated-src/wsdl2java/”,
“${projectDir}/src/main/webapp/WEB-INF/wsdl/${webservice.wsdl}”]

doLast {
  FileTree tree = fileTree(dir: "${buildDir}/generated-src/wsdl2java/")
  tree.include "**/*Impl.java"
  tree.include "**/*TO.java"
  project.delete(tree)
}

}

compileJava.dependsOn “wsdl2java${webservice.wsdl}”

}

Error as below:

:Retail-Services-SERVICE:jar
:Retail-Services-WEB:wsdl2javaAWDService.wsdl
The command line is too long.
:Retail-Services-WEB:wsdl2javaAWDService.wsdl FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:Retail-Services-WEB:wsdl2javaAWDService.wsdl’.

Process ‘command ‘cmd’’ finished with non-zero exit value 1

  • Try:
    Run with --info or --debug option to get more log output.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:Retail-Services-WEB:wsdl2javaAWDService.wsdl’.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)

It works by this.

configurations.runtime.files*.name.join(" ")