Skip to content

Task API

TIP

The Worker API is the preferred approach for JavaScript code generation

The Task API approach uses Gradle tasks to execute the wsdl2js tool. For each WSDL document to process, you must create a separate Gradle task of type Wsdl2Js.

The Wsdl2Js task is provided by this plugin and is a subclass of Gradle's JavaExec. As such, any and all configuration options available on JavaExec are also available on Wsdl2Js.

Configuration

For each WSDL document to process, create a task that holds the configuration. The task should be of type of Wsdl2Js. Create the task using your preferred method of task creation.

The following example shows a single task named example that processes the example.wsdl document:

kotlin
import io.mateo.cxf.codegen.wsdl2js.Wsdl2Js

// ...

tasks.register("example", Wsdl2Js::class) { // <1>
    toolOptions { // <2>
        wsdl = file("path/to/example.wsdl").absolutePath // <3>
    }
}
groovy
import io.mateo.cxf.codegen.wsdl2js.Wsdl2Js

// ...

tasks.register("example", Wsdl2Js) { // <1>
    toolOptions { // <2>
        wsdl = file("path/to/example.wsdl").absolutePath // <3>
    }
}

By convention, the generated JavaScript sources will be created in the$buildDir/$name-wsdl2js-generated-sources directory where $name is the task name.

Tool Options

The Wsdl2Js task type provides type-safe properties that map to the underlying wsdl2js tool options. The properties are all lazy properties. Their values are realized when the task is executed.

The table below lists the available properties, descriptions, and type. These are a direct mapping to the wsdl2js tool options listed in the tool's documentation here.

These options should be configured within the toolOptions { } block as shown above in Configuration.

TypeNameDescription
Property<String>wsdlThe WSDL to process. The value can either be a direct path to a file on a local system or URL to a remote file.
DirectoryPropertyoutputDirectorySpecifies the directory the generated code files are written. If not set, the convention is build/$name-wsdl2js-generated-sources. The $name variable is the option name
Property<String>wsdlVersionSpecifies the WSDL version. If not set, wsdl2js defaults to WSDL1.1; currently supports only WSDL1.1 version.
ListProperty<UriPrefixPair>packagePrefixesSpecifies a mapping between the namespaces used in the WSDL document and the prefixes used in the generated JavaScript.
Property<String>catalogSpecify catalog file to map the imported WSDL/schema.
Property<String>validateEnables validating the WSDL before generating the code.
Property<Boolean>verboseEnables or disables verbosity.
Property<Boolean>quietEnables or disables quiet mode. When enabled, suppresses comments during the code generation process.

Logging

Refer to the logging documentation for generating Java code for details; the configuration is the same.

Released under Apache 2.0 license