Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 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
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
202 changes: 103 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,31 @@
### Deprecation notice
### Note

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.
* 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/

### 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.

#### 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

### CXF
This plugin uses the apache-cxf tools to do the actual work.
(Version must be defined in gradle task config!)

### Tasks

| 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

Expand All @@ -53,25 +39,18 @@ 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 '3.0.0'
}

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

Kotlin:

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

Expand All @@ -81,11 +60,13 @@ plugins {
| ------ | ------------- | ----------- |
| 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. |
| cxfVersion | "+" | Controls the CXF version used to generate code. |
| cxfPluginVersion | "+" | Controls the CXF XJC-plugins version used to generate code. |
| cxfVersion | none, has to be specified | Controls the CXF version used to generate code. |
| cxfPluginVersion | none, has to be specified | Controls the CXF XJC-plugins version used to generate code. |
| includeJava8XmlDependencies | true | If on Java 9 or later this flag includes xml libraries that were previously included with the JRE. Set to false if you use recent versions of Java and the Jakarta xml implementations. |

Example setting of options:

Expand All @@ -99,16 +80,16 @@ wsdl2java {
['-xjc','-b','bindingfile.xml','src/main/resources/wsdl/secondwsdl.wsdl']
]
locale = Locale.GERMANY
cxfVersion = "2.5.1"
cxfPluginVersion = "2.4.0"
cxfVersion = "4.0.0"
cxfPluginVersion = "4.0.0"
}
```

Kotlin:

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

wsdl2java {
wsdlDir = file("$projectDir/src/main/wsdl")
Expand All @@ -119,61 +100,98 @@ wsdl2java {
}
```

### 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 3+ 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 "3.0.1"
id "io.spring.dependency-management" version "1.1.0"
id "com.yupzip.wsdl2java" version "3.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.
bootJar {
duplicatesStrategy(DuplicatesStrategy.WARN)
}

```groovy
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.12'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
options.compilerArgs << '-parameters'
}

apply plugin: 'java'
apply plugin: 'no.nils.wsdl2java'
sourceSets.main.java.srcDirs "src/generated-sources/java"

repositories {
mavenCentral()
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.1'
implementation 'com.sun.xml.messaging.saaj:saaj-impl:3.0.0'
implementation 'com.sun.xml.ws:jaxws-ri:4.0.0'

implementation 'io.swagger.core.v3:swagger-jaxrs2-jakarta:2.2.7'

implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
implementation 'jakarta.xml.soap:jakarta.xml.soap-api:3.0.0'
implementation 'jakarta.xml.ws:jakarta.xml.ws-api:4.0.0'

implementation 'org.jvnet.jaxb2_commons:jaxb2-namespace-prefix:2.0'
implementation 'codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0'
implementation 'codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0'

implementation 'org.apache.cxf.xjc-utils:cxf-xjc-runtime:4.0.0'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.1'
}

configurations {
wsdl2java
}

dependencies {
testCompile 'junit:junit:+'
wsdl2java (
'com.sun.xml.bind:jaxb-impl:4.0.1',
'org.apache.cxf.xjc-utils:cxf-xjc-runtime:4.0.0',
'jakarta.xml.ws:jakarta.xml.ws-api:4.0.0',
'com.sun.xml.ws:rt:4.0.0',
'org.jvnet.jaxb2_commons:jaxb2-namespace-prefix:2.0',
'codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0',
'codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0'
)
}

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

Expand All @@ -184,10 +202,10 @@ This plugin automatically adds the necessary dependencies to work on Java 9+ whe
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 "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"
```

Expand All @@ -198,7 +216,7 @@ To use those extensions some more dependencies are necessary.

```groovy
dependencies() {
compile 'org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.11.0'
implementation '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'
Expand All @@ -212,22 +230,8 @@ wsdl2java{
}
```

This example creates the hashCode and the equals method.
This example creates hashCode and equals methods.

### 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