| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Gradle plugin for generating Java classes from WSDL files, using Apache CXF under the hood.
Maintained fork of the deprecated nilsmagnus/wsdl2java, updated for modern Gradle and current CXF / JAXB versions.
Groovy:
plugins {
id 'java'
id 'com.yupzip.wsdl2java' version '4.1.0'
}Kotlin:
plugins {
id("java")
id("com.yupzip.wsdl2java") version "4.1.0"
}wsdl2java {
wsdlDir = "src/main/resources/wsdl"
wsdlsToGenerate = [
['src/main/resources/wsdl/firstwsdl.wsdl'],
['-xjc', '-b', 'bindingfile.xml', 'src/main/resources/wsdl/secondwsdl.wsdl']
]
locale = Locale.GERMANY
}The plugin automatically adds generatedWsdlDir (default: build/generated/wsdl) to sourceSets.main.java.srcDirs, so the generated classes compile without any further setup.
| Name | Description |
|---|---|
| wsdl2javaTask | Generates Java sources from WSDL files. Wired as a dependency of compileJava (and of compileKotlin when Kotlin applies). |
| Option | Type | Default | Description |
|---|---|---|---|
| wsdlDir | String | src/main/resources/wsdl | Source directory of WSDL files. Used for the incremental-build input check — changes here invalidate the cached task output. |
| wsdlsToGenerate | List<List<String>> | required | 2D list of CXF wsdl-to-java argument vectors. The last element of each inner list must be the WSDL path. See the CXF reference. |
| generatedWsdlDir | String | build/generated/wsdl | Destination directory for generated sources. |
| locale | Locale | Locale.getDefault() | Locale used while CXF generates JavaDoc. Set explicitly for reproducible output across machines. |
| encoding | String | platform default | Encoding for the generated source files (e.g. UTF-8, EUC-JP). |
| lineEnding | LineEnding | PLATFORM_NATIVE | Line endings in the generated files. One of PLATFORM_NATIVE, WINDOWS (\r\n), UNIX (\n), MAC_CLASSIC (\r). |
| stabilize | boolean | false | Post-process generated sources to produce diff-friendly output: strip generation timestamps and stable-sort @XmlSeeAlso, @XmlElementRef, and consecutive {@link …} JavaDoc lines. |
| stabilizeAndMergeObjectFactory | boolean | false | When multiple WSDLs target the same Java package, merge their generated ObjectFactory classes into a single, stably ordered file instead of letting the last write win. |
The plugin resolves CXF tooling against a fixed set of versions by default. Each is overridable via the extension:
| Option | Default | Affects |
|---|---|---|
| cxfVersion | 4.2.0 | org.apache.cxf.xjc-utils:cxf-xjc-runtime |
| cxfPluginVersion | 4.2.0 | org.apache.cxf.xjcplugins:cxf-xjc-ts, org.apache.cxf.xjcplugins:cxf-xjc-boolean |
| cxfToolsVersion | 4.2.1 | org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb, org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws |
| jaxb2NamespacePrefixVersion | 2.0 | org.jvnet.jaxb2_commons:jaxb2-namespace-prefix |
| jaxb2BasicsVersion | 3.0.0 | codes.rafael.jaxb2_commons:jaxb2-basics, codes.rafael.jaxb2_commons:jaxb2-basics-runtime |
Example:
wsdl2java {
cxfVersion = "4.1.2"
cxfPluginVersion = "4.1.2"
cxfToolsVersion = "4.2.0"
// …rest of config
}So that generated code compiles and runs without extra setup, the plugin adds the following to your implementation configuration if they aren't already declared:
If you already declare these explicitly (any version), the plugin leaves them alone.
plugins {
id "java"
id "org.springframework.boot" version "4.0.6"
id "io.spring.dependency-management" version "1.7.0"
id "com.yupzip.wsdl2java" version "4.1.0"
}
bootJar {
duplicatesStrategy(DuplicatesStrategy.WARN)
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
options.compilerArgs << '-parameters'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.ws:spring-ws-support:4.0.0'
// your project dependencies
implementation 'com.sun.xml.bind:jaxb-impl:4.0.6'
implementation 'com.sun.xml.messaging.saaj:saaj-impl:3.0.4'
implementation 'com.sun.xml.ws:jaxws-ri:4.0.3'
implementation 'io.swagger.core.v3:swagger-jaxrs2-jakarta:2.2.7'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.5'
implementation 'jakarta.xml.soap:jakarta.xml.soap-api:3.0.2'
implementation 'jakarta.xml.ws:jakarta.xml.ws-api:4.0.3'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.6'
}
configurations {
wsdl2java
}
wsdl2java {
wsdlDir = "$projectDir/src/main/resources/wsdl/"
stabilizeAndMergeObjectFactory = true
wsdlsToGenerate = [
['-xjc',
'-xjc-Xnamespace-prefix',
'-b', "$projectDir/src/main/resources/wsdl/wsdlBindings.xml",
'-b', "$projectDir/src/main/resources/wsdl/wsdlTypeDefBindings.xjb",
'-wsdlLocation', 'classPath:wsdl/myWsdl.wsdl',
'-p', 'my.package',
'-autoNameResolution',
'-verbose',
"$projectDir/src/main/resources/wsdl/myWsdl.wsdl"
],
['-xjc',
'-xjc-Xnamespace-prefix',
'-b', "$projectDir/src/main/resources/wsdl/wsdlBindings2.xml",
'-b', "$projectDir/src/main/resources/wsdl/wsdlTypeDefBindings2.xjb",
'-wsdlLocation', 'classPath:wsdl/myWsdl2.wsdl',
'-p', 'my.package',
'-autoNameResolution',
'-verbose',
"$projectDir/src/main/resources/wsdl/myWsdl2.wsdl"
]
]
generatedWsdlDir = "src/generated-sources/java"
}Prefer $projectDir over absolute paths in your build file, as shown above. This keeps the build portable across developer machines and CI agents.
sourceSets.main.java.srcDirs "src/generated-sources/java"Please file an issue at https://github.com/yupzip/wsdl2java/issues.
Contributions are welcome.
| Back | FazBrowse Home | New Git URL |