WSDL Builder Gradle Plugin

The WSDL Builder Gradle plugin lets you generate Apache Axis client stubs from Web Service Description (WSDL) files.

The plugin has been successfully tested with Gradle 4.10.2.

Usage

To use the plugin, include it in your build script:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.wsdl.builder", version: "2.0.3"
    }

    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}

apply plugin: "com.liferay.wsdl.builder"

The WSDL Builder plugin automatically applies the java plugin.

Since the plugin automatically resolves the Apache Axis library as a dependency, you have to configure a repository that hosts the library and its transitive dependencies. The Liferay CDN repository hosts them all:

repositories {
    maven {
        url "https://repository-cdn.liferay.com/nexus/content/groups/public"
    }
}

Tasks

The plugin adds one main task to your project:

NameDepends OnTypeDescription
buildWSDL-BuildWSDLTaskGenerates WSDL client stubs.

By default, the buildWSDL task looks for WSDL files in the ${project.projectDir}/wsdl directory. If the war plugin is applied, it looks in the ${project.webAppDir}/WEB-INF/wsdl directory.

For each WSDL file that can be found, the task generates client stubs via direct invocation of the WSDL2Java tool, saving them in the first java directory of the main source set (by default: src/main/java).

If configured to do so, buildWSDL can instead save the client stub Java files in a temporary directory, compile them, and package them in JAR files. The JAR files are named after the WSDL file and saved in ${project.projectDir}/lib, by default, or in ${project.webAppDir}/WEB-INF/lib, if the war plugin is applied.

BuildWSDLTask

Tasks of type FormatWSDLTask extend SourceTask, so all its properties and methods, such as include and exclude, are available.

Task Properties

Property NameTypeDefault ValueDescription
buildLibsbooleantrueWhether to package the client stub classes of each WSDL file in JAR files, saved to the directory the destinationDir property references. If false, the task generates the client stub Java files to the destinationDir directory.
destinationDirFilenullA directory where the client stub Java files (if buildLibs is false) or the client stub JAR files (if buildLibs is true) are saved.
generateOptions.mappingMap[:]Namespace-to-package mappings (sets the --NStoPkg argument in the WSDL2Java invocation). It is possible to use a Closure or a Callable, to defer evaluation until task execution..
generateOptions.noWrappedbooleanfalseWhether to turn off support for “wrapped” document/literal (sets the --noWrapped argument in the WSDL2Java invocation).
generateOptions.serverSidebooleanfalseWhether to emit server-side bindings for the web service (sets the --server-side argument in the WSDL2Java invocation).
generateOptions.verbosebooleanfalseWhether to print informational messages (sets the --verbose argument in the WSDL2Java invocation).
includeSourcebooleantrueWhether to package the client stub Java files in the JAR file’s OSGI-OPT/src directory. If buildLibs is false, this property has no effect.
includeWSDLsbooleantrueWhether to configure the processResources task to include the WSDL files in the project JAR’s wsdl directory.

The properties of type File support any type that can be resolved by project.file.

Task Methods

Method SignatureDescription
generateOptions.mapping(Object namespace, Object packageName)Adds a namespace-to-package mapping.
generateOptions.mappings(Map mappings)Adds multiple namespace-to-package mappings.

Helper Tasks

At the end of the project evaluation, a series of helper tasks are created for each WSDL file returned by the source property of the BuildWSDLTask tasks. The names of the helper tasks start with the WSDL file name, without any extension.

  • ${WSDL file title}Generate of type JavaExec: invokes WSDL2Java to generate the client stubs for the WSDL file.

If buildWSDLTask.buildLibs is true, the following helper tasks are also created:

  • ${WSDL file title}Compile of type JavaCompile: compiles the client stub Java files for the WSDL file.
  • ${WSDL file title}Jar of type Jar: packages in a JAR file called ${WSDL file title}-ws.jar, the client stub for the WSDL file.

Additional Configuration

There are additional configurations that can help you use WSDL Builder.

Apache Axis Dependency

By default, the plugin creates a configuration called wsdlBuilder and adds the following dependencies:

  • axis:axis-wsdl4j:1.5.1
  • com.liferay:org.apache.axis:1.4.LIFERAY-PATCHED-1
  • commons-discovery:commons-discovery:0.2
  • commons-logging:commons-logging:1.0.4
  • javax.activation:activation:1.1
  • javax.mail:mail:1.4
  • org.apache.axis:axis-jaxrpc:1.4
  • org.apache.axis:axis-saaj:1.4

It is possible to override this setting and use a specific version of Apache Axis, by manually populating the wsdlBuilder configuration with the desired dependencies.

« WSDD Builder Gradle PluginXML Formatter Gradle Plugin »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0