Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
51a635e
1.0
pvermes May 1, 2021
93a8c8f
1.0
pvermes May 1, 2021
f90884d
1.0
pvermes May 1, 2021
0932b0c
1.0
pvermes May 1, 2021
fb64a24
2.0 - configurable outputdir
pvermes May 4, 2021
0ea4639
readme.md
pvermes May 22, 2021
7f839a9
Task and extension should use different names
nicklascarnegie Aug 11, 2021
d4758f6
Bump version
nicklascarnegie Aug 11, 2021
93b4563
Merge pull request #1 from nicklasbondesson/fix-task-name
yupzip Aug 11, 2021
9726291
readme.md
pvermes Aug 11, 2021
fecfbae
readme.md - adding Nicklas as contributor
yupzip Aug 11, 2021
8e91abc
Fix kotlin detection
nicklascarnegie Aug 11, 2021
262383a
Bump version
nicklascarnegie Aug 11, 2021
a8adb29
Merge pull request #2 from nicklasbondesson/fix-kotlin-detection
yupzip Aug 11, 2021
d7a1900
2.1.1
yupzip Aug 11, 2021
78e62b2
Additional changes included in 2.1
yupzip Aug 11, 2021
0ed4842
Remove unused method
nicklascarnegie Aug 12, 2021
b83ad29
Improved up-to-date checks
nicklascarnegie Aug 12, 2021
ebfcd4a
Bump version
nicklascarnegie Aug 12, 2021
d5c618c
Update README
nicklascarnegie Aug 12, 2021
d25c7cb
Merge pull request #3 from nicklasbondesson/remove-unused-method
yupzip Aug 12, 2021
75f2ef5
Merge pull request #4 from nicklasbondesson/improve-up-tp-date-checks
yupzip Aug 12, 2021
c6e707a
2.1.1
yupzip Aug 12, 2021
09ffc05
2.2
yupzip Aug 12, 2021
0eef05c
2.2.0
yupzip Aug 12, 2021
aec986a
Add a flag to exclude java 8 xml dependencies during runtime
Nov 19, 2021
c2a1e32
Update readme for new flag
Nov 19, 2021
87c0abe
Merge pull request #5 from hschindel/xml-dependency-flag
yupzip Nov 30, 2021
943d1e4
README.md - version
yupzip Nov 30, 2021
350aeda
MISC: Updated plugin to reference ArrayList .size() instead of .size …
Apr 26, 2022
e6ca7d0
Merge pull request #6 from mishimaltd/feature/fix-groovy-compilation-…
yupzip Jun 24, 2022
3ce3a6f
Merge remote-tracking branch 'origin/master'
yupzip Jun 24, 2022
cb5c5be
2.3.1
yupzip Jun 24, 2022
f8a6de0
Add lineEnding extension property to configure generated files line e…
PaulFridrick Nov 7, 2022
86128ba
Merge pull request #7 from PaulFridrick/feat_line-ending-extension
yupzip Dec 2, 2022
361df79
2.3.2
yupzip Dec 2, 2022
ed3cced
Require the user to specify cxfVersion and cxfPluginVersion
Dec 23, 2022
0de8d1c
Merge pull request #8 from mpevnev/master
yupzip Jan 11, 2023
9d15879
3.0.0
yupzip Jan 12, 2023
17b6a7d
README.md
yupzip Jan 12, 2023
3eaf468
Adaption for Gradle 9
cstsw Mar 23, 2026
bf027d4
Merge pull request #9 from cstsw/master
yupzip Mar 25, 2026
2ee8fc8
3.0.1
yupzip Mar 25, 2026
61af238
4.0.0
yupzip Mar 25, 2026
c56c964
4.0.0
yupzip Mar 25, 2026
2af78ee
4.0.0
yupzip Mar 25, 2026
9c2d4f6
4.0.0
yupzip Mar 25, 2026
ef5c415
4.0.0
yupzip Mar 25, 2026
3360f27
4.0.0
yupzip Mar 25, 2026
3141932
4.0.0
yupzip Mar 25, 2026
250656b
4.0.0
yupzip Mar 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ repo/
consumer/generated*
out
.DS_Store
./gradle.properties
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Nils Larsgård, nilsmagnus@gmail.com
Copyright (c) 2021 Peter Vermes, peter.vermes@yupzip.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
243 changes: 98 additions & 145 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
### Deprecation notice

This plugin is no longer maintained by its creator since I dont have any interest in using this plugin anymore and find no pleasure in maintaining it for free/fun. Please fork it and use it as you like. The plugin is not published to any relevant plugin-portals.
### Note

* Version 4.0.0
* Plugin built with Gradle 9.4.1
* JDK 17+ required
* CXF Tool version 4.1.2 (cxfVersion property removed)
* CXF Plugin version 4.1.2 (cxfPlugin property removed)
* CXF Tools version 4.2.0
* JAXB2 naming prefix version 2.0 (org.jvnet.jaxb2_commons:jaxb2-namespace-prefix)
* JAXB2 basic plugins version 3.0.0 (org.codes.rafael.jaxb2_commons:jaxb2-basics)
* wsdlDir property is now a string
* generatedWsdlDir property is now a string
* inclusion of generated classes in source to be configured in build.gradle, e.g.:
```groovy
sourceSets.main.java.srcDirs "src/generated-sources/java"
```
* Version 3.0.1 - adaption for Gradle 9
* Version 3.0.0 contains a breaking change: 'cxfVersion' and 'cxfPluginVersion' properties are now required.
* This plugin is forked from deprecated nilsmagnus/wsdl2java to make the plugin compatible with Gradle 7+.

wsdl2java gradle plugin
=========

[![Known Vulnerabilities](https://snyk.io/test/github/nilsmagnus/wsdl2java/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/nilsmagnus/wsdl2java?targetFile=build.gradle)
[![Build Status](https://cloud.drone.io/api/badges/nilsmagnus/wsdl2java/status.svg)](https://cloud.drone.io/nilsmagnus/wsdl2java)
[ ![Download](https://api.bintray.com/packages/nilsmagnus/maven/wsdl2java/images/download.svg?version=0.12) ](https://bintray.com/nilsmagnus/maven/wsdl2java/0.12/link)

Gradle plugin for generating java from wsdl, using cxf under the hood and the same options as the maven wsdl-2-java plugin from apache-cxf.

The plugin binaries are downloadable from bintray: https://bintray.com/nilsmagnus/maven/wsdl2java/
Gradle plugin for generating java classes from wsdl using CXF under the hood.

### Issues
If you have any issues with the plugin, please file an issue at github, https://github.com/nilsmagnus/wsdl2java/issues
If you have any issues with the plugin, please file an issue at github, https://github.com/yupzip/wsdl2java/issues

### Contribution
Contributions are welcome as long as they are sane.
Contributions are welcome.

#### Contributors
- Nils Larsgård , https://github.com/nilsmagnus
- Mats Faugli, https://github.com/fowlie
- Thorben Schiller, https://github.com/thorbolo
- Stefan Kloe, https://github.com/Pentadrago
- Mattias Rundgren, https://github.com/matrun
- Steffen Döring, https://github.com/s-doering
- Jesper Skov, https://github.com/jskovjyskebankdk
- Manuel Sanches Ortiz, https://github.com/manuelsanchezortiz
- Ruben Gees, https://github.com/rubengees
- Stefan Krause-Kjær, https://github.com/KrauseStefan
- Peter Vermes , https://github.com/yupzip
- Nicklas Bondesson , https://github.com/nicklasbondesson
- https://github.com/cstsw

### CXF
This plugin uses the apache-cxf tools to do the actual work.
Expand All @@ -38,13 +40,11 @@ This plugin uses the apache-cxf tools to do the actual work.

| Name | Description | Dependecy |
| ---- | ----------- | --------- |
| wsdl2java | Generate java source from wsdl-files | CompileJava/CompileKotlin depends on wsdl2java |
| ~~xsd2java~~ | ~~Generate java source from xsd-files~~ Removed in version 0.8 | ~~CompileJava depends on xsd2java~~ |
| wsdl2javaTask | Generate java source from wsdl-files | CompileJava/CompileKotlin depends on wsdl2java |

## Usage

To use this plugin, you must
- modify your buildscript to have dependencies to the plugin
- apply the plugin
- set the properties of the plugin

Expand All @@ -53,181 +53,134 @@ To use this plugin, you must
Groovy:

```groovy
buildscript{
repositories{
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.12'
}
plugins {
id 'java'
id 'com.yupzip.wsdl2java' version '4.0.0'
}

apply plugin: 'no.nils.wsdl2java'
```

Kotlin:

```kotlin
plugins {
id("java")
id("no.nils.wsdl2java") version "0.12"
id("com.yupzip.wsdl2java") version "4.0.0"
}
```

### Plugin options

| Option | Default value | Description |
| ------ | ------------- | ----------- |
| wsdlDir | src/main/resources | Define the wsdl files directory to support incremental build. This means that the task will be up-to-date if nothing in this directory has changed. |
| wsdlsToGenerate | empty | This is the main input to the plugin that defines the wsdls to process. It is a list of arguments where each argument is a list of arguments to process a wsdl-file. The Wsdl-file with full path is the last argument. The array can be supplied with the same options as described for the maven-cxf plugin(http://cxf.apache.org/docs/wsdl-to-java.html). |
| locale | Locale.getDefault() | The locale for the generated sources – especially the JavaDoc. This might be necessary to prevent differing sources due to several development environments. |
| encoding | platform default encoding | Set the encoding name for generated sources, such as EUC-JP or UTF-8. |
| stabilizeAndMergeObjectFactory| false | If multiple WSDLs target the same package, merge their `ObjectFactory` classes. |
| cxfVersion | "+" | Controls the CXF version used to generate code. |
| cxfPluginVersion | "+" | Controls the CXF XJC-plugins version used to generate code. |
| Option | Default value | Description |
|--------------------------------|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| wsdlDir | src/main/resources | Define the wsdl files directory to support incremental build. This means that the task will be up-to-date if nothing in this directory has changed. |
| wsdlsToGenerate | empty | This is the main input to the plugin that defines the wsdls to process. It is a list of arguments where each argument is a list of arguments to process a wsdl-file. The Wsdl-file with full path is the last argument. The array can be supplied with the same options as described for the maven-cxf plugin(http://cxf.apache.org/docs/wsdl-to-java.html). |
| generatedWsdlDir | build/generated/wsdl | Destination directory for generated sources. The task will be up-to-date if nothing in this directory changes between builds. |
| locale | Locale.getDefault() | The locale for the generated sources – especially the JavaDoc. This might be necessary to prevent differing sources due to several development environments. |
| encoding | platform default encoding | Set the encoding name for generated sources, such as EUC-JP or UTF-8. |
| stabilizeAndMergeObjectFactory | false | If multiple WSDLs target the same package, merge their `ObjectFactory` classes. |

Example setting of options:

Groovy:

```groovy
wsdl2java {
wsdlDir = file("src/main/resources/myWsdlFiles") // define to support incremental build
wsdlDir = "src/main/resources/myWsdlFiles"
wsdlsToGenerate = [ // 2d-array of wsdls and cxf-parameters
['src/main/resources/wsdl/firstwsdl.wsdl'],
['-xjc','-b','bindingfile.xml','src/main/resources/wsdl/secondwsdl.wsdl']
]
locale = Locale.GERMANY
cxfVersion = "2.5.1"
cxfPluginVersion = "2.4.0"
}
```

Kotlin:

```kotlin
extra["cxfVersion"] = "3.3.2"
extra["cxfPluginVersion"] = "3.2.2"

wsdl2java {
wsdlDir = file("$projectDir/src/main/wsdl")
wsdlDir = "$projectDir/src/main/wsdl"
wsdlsToGenerate = listOf(
listOf("$wsdlDir/firstwsdl.wsdl"),
listOf("-xjc", "-b", "bindingfile.xml", "$wsdlDir/secondwsdl.wsdl")
)
}
```

### Options for xsd2java (deprecated, separate plugin coming soon)

This will not work for version 0.8+!

| Option | Default value | Description |
| ------ | ------------- | ----------- |
| generatedXsdDir | "generatedsources/src/main/java" | Destination directory for generated sources |
| xsdsToGenerate | null | 2-d array consisting of 2 or 3 values in each array: 1. xsd-file(input), 2. package for the generated sources, 3. (optional) a map containing additional options for the xjc task |
| encoding | platform default encoding | Set the encoding name for generated sources, such as EUC-JP or UTF-8. |

Example setting of options:

## Example gradle configuration for Spring Boot 4+ with jakarta namespace
```groovy
xsd2java {
encoding = 'utf-8'
xsdsToGenerate = [
["src/main/resources/xsd/CustomersAndOrders.xsd", 'no.nils.xsd2java.sample', [header: false] /* optional map */]
]
generatedXsdDir = file("generatedsources/xsd2java")
plugins {
id "java"
id "org.springframework.boot" version "4.0.4"
id "io.spring.dependency-management" version "1.7.0"
id "com.yupzip.wsdl2java" version "4.0.0"
}
```

## Complete example usage
This is a an example of a working build.gradle for a java project. You can also take a look at the test resources, which contain two working projects.

```groovy
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.12'
}
bootJar {
duplicatesStrategy(DuplicatesStrategy.WARN)
}

apply plugin: 'java'
apply plugin: 'no.nils.wsdl2java'

repositories {
mavenCentral()
compileJava {
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
options.compilerArgs << '-parameters'
}

dependencies {
testCompile 'junit:junit:+'
}
sourceSets.main.java.srcDirs "src/generated-sources/java"

wsdl2java {
wsdlsToGenerate = [
['-p', 'com.acme.mypackage', '-autoNameResolution', "$projectDir/src/main/resources/wsdl/stockqoute.wsdl"]
]
wsdlDir = file("$projectDir/src/main/resources/wsdl")
locale = Locale.FRANCE
cxfVersion = "2.5.1"
cxfPluginVersion = "2.4.0"
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'
}
```

### Java 9+ support

This plugin automatically adds the necessary dependencies to work on Java 9+ when detected.

As of now, these dependencies are added:

```groovy
implementation "javax.xml.bind:jaxb-api:2.3.1",
implementation "javax.xml.ws:jaxws-api:2.3.1",
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2",
implementation "org.glassfish.main.javaee-api:javax.jws:3.1.2.2",
implementation "com.sun.xml.messaging.saaj:saaj-impl:1.5.1"
```

## Enable basic extension support for xjc

Apache CXF supports [extension for xjc](http://confluence.highsource.org/display/J2B/JAXB2+Basics+Plugins), e.g. for creating a hashCode, equals and toString method in the classes generated by xjc.
To use those extensions some more dependencies are necessary.

```groovy
dependencies() {
compile 'org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.11.0'

// enable extension support for wsdl2java
wsdl2java 'org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.11.0'
wsdl2java 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0'
configurations {
wsdl2java
}

wsdl2java{
wsdl2java {
wsdlDir = "$projectDir/src/main/resources/wsdl/"
stabilizeAndMergeObjectFactory = true
wsdlsToGenerate = [
['-xjc-Xequals', '-xjc-XhashCode', 'src/main/resources/com/example/api/interface.wsdl']
['-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"
}
```

This example creates the hashCode and the equals method.

### A notice on multi-module projects

Instead of referring to absolute paths in your build-file, try using $projectDir as a prefix to your files and directories. As shown in the "Complete example usage".


# Releasing

* set version to final in build.gradle & commit

* build artifact and upload

export BINTRAY_USER=<bintrayuser>
export BINTRAY_API_KEY=<apikey>
./gradlew clean bintrayPublish bintrayUpload

* increment version and set to SNAPSHOT & commit
* git push
Loading