Skip to content

Commit 7cf189a

Browse files
committed
feature parity with wsdl2java
1 parent 3988d41 commit 7cf189a

File tree

7 files changed

+328
-77
lines changed

7 files changed

+328
-77
lines changed

README.md

+48-30
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ Contributions are welcome as long as they are sane.
2121
- "s-doering", https://github.com/s-doering
2222

2323
### CXF
24-
This plugin uses the apache-cxf tools to do the actual work.
24+
This plugin uses the xjc tool to do the actual work.
2525

2626
### Tasks
2727

2828
| Name | Description | Dependecy |
2929
| ---- | ----------- | --------- |
30-
| wsdl2java | Generate java source from wsdl-files | CompileJava depends on wsdl2java |
31-
| ~~xsd2java~~ | ~~Generate java source from xsd-files~~ Removed in version 0.8 | ~~CompileJava depends on xsd2java~~ |
32-
| deleteGeneratedSources | Delete all generated sources | Clean depends on deleteGeneratedSources |
30+
| xsd2java | Generate java source from wsdl-files | CompileJava depends on xsd2java |
31+
| deleteGeneratedXsdSources | Delete all generated sources | Clean depends on deleteGeneratedXsdSources |
3332

3433
## Usage
3534

@@ -47,44 +46,67 @@ To use this plugin, you must
4746
mavenCentral()
4847
}
4948
dependencies {
50-
classpath 'no.nils:xsd2java:0.8'
49+
classpath 'no.nils:xsd2java:0.6'
5150
}
5251
}
5352
apply plugin: 'no.nils.xsd2java'
5453

54+
### Plugin options
5555

56+
| Option | Default value | Description |
57+
| ------ | ------------- | ----------- |
58+
| jaxbVersion | "+" | Controls the JAXB version used to generate code.
59+
| deleteGeneratedSourcesOnClean | true | If you want to keep the generated sources under version control, set this option to false. |
60+
61+
62+
Example of specifying another JAXB version:
63+
64+
xsd2javaExt {
65+
jaxbVersion = "0.11.0"
66+
}
5667

57-
5868

59-
### Options for xsd2java (deprecated, separate plugin coming soon)
60-
This will not work for version 0.8+!
69+
Example of retaining the generated sources on clean:
70+
71+
xsd2javaExt {
72+
deleteGeneratedSourcesOnClean = false
73+
}
74+
75+
### Options for xsd2java
6176
| Option | Default value | Description |
6277
| ------ | ------------- | ----------- |
63-
| generatedXsdDir | "generatedsources/src/main/java" | Destination directory for generated sources |
64-
| 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 |
78+
| generatedXsdDir | "generatedsources/src/main/java" | Destination directory for generated sources sources to be placed. |
79+
| xsdDir | src/main/resources | Define the xsd files directory to support incremental build. This means that the task will be up-to-date if nothing in this directory has changed. |
80+
| wsdlsToGenerate | empty | This is the main input to the plugin that defines the xsds to process. It is a list of arguments where each argument is a list of arguments to process a xsd-file. The xsd-file with full path is the last argument. The array can be supplied with the same options as described for the jaxb plugin(https://jaxb.java.net/2.2.4/docs/xjc.html). |
6581
| encoding | platform default encoding | Set the encoding name for generated sources, such as EUC-JP or UTF-8. |
82+
| 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. |
83+
| stabilizeAndMergeObjectFactory| false | If multiple XSDs target the same package, merge their ObjectFactory.java classes |
6684

6785
Example setting of options:
6886

69-
xsd2java{
87+
xsd2java {
88+
generatedXsdDir = file("generatedsources/xsd2java") // target directory for generated source coude
89+
xsdDir = file("src/main/resources/myXsdFiles") // define to support incremental build
90+
xsdsToGenerate = [ // 2d-array of xsds and xjc-parameters
91+
['src/main/resources/xsd/firstxsd.xsd'],
92+
['-p','no.nils.xsd2java.sample','-verbose','src/main/resources/xsd/secondxsd.xsd']
93+
]
94+
locale = Locale.GERMANY
7095
encoding = 'utf-8'
71-
xsdsToGenerate = [
72-
["src/main/resources/xsd/CustomersAndOrders.xsd", 'no.nils.xsd2java.sample', [header: false] /* optional map */]
73-
]
74-
generatedXsdDir = file("generatedsources/xsd2java")
7596
}
7697

7798

99+
78100
## Complete example usage
79-
This is a an example of a working build.gradle for a java project. You can also take a look at this projects submodule "consumer" which has a working wsdl compiling.
101+
This is a an example of a working build.gradle for a java project. You can also take a look at this projects submodule "consumer" which has a working xsd compiling.
80102

81103
buildscript{
82104
repositories{
83105
jcenter()
84106
mavenCentral()
85107
}
86108
dependencies {
87-
classpath 'no.nils:wsdl2java:0.8'
109+
classpath 'no.nils:xsd2java:0.6'
88110
}
89111
}
90112

@@ -99,19 +121,15 @@ This is a an example of a working build.gradle for a java project. You can also
99121
testCompile 'junit:junit:+'
100122
}
101123

102-
wsdl2java{
103-
wsdlsToGenerate = [
104-
["$projectDir/src/main/resources/wsdl/stockqoute.wsdl"]
105-
]
106-
generatedWsdlDir = file("$projectDir/generatedsources")
107-
wsdlDir = file("$projectDir/src/main/resources/wsdl")
108-
cxfVersion = "3.0.1"
109-
}
110-
xsd2java{
111-
xsdsToGenerate = [
112-
["$projectDir/src/main/resources/xsd/CustomersAndOrders.xsd", 'no.nils.xsd2java.sample']
113-
]
114-
generatedXsdDir = file("$projectDir/generatedsources/xsd2java")
124+
xsd2java {
125+
generatedXsdDir = file("generatedsources/xsd2java") // target directory for generated source coude
126+
xsdDir = file("src/main/resources/myXsdFiles") // define to support incremental build
127+
xsdsToGenerate = [ // 2d-array of xsds and xjc-parameters
128+
['src/main/resources/xsd/firstxsd.xsd'],
129+
['-p','no.nils.xsd2java.sample','-verbose','src/main/resources/xsd/secondxsd.xsd']
130+
]
131+
locale = Locale.GERMANY
132+
encoding = 'utf-8'
115133
}
116134

117135
### A notice on multi-module projects

plugin/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828
}
2929

3030
group = 'no.nils'
31-
version = '0.1-SNAPSHOT'
31+
version = '0.6-SNAPSHOT'
3232

3333
uploadArchives {
3434
repositories {

plugin/src/main/groovy/no/nils/xsd2java/CleanTask.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package no.nils.xsd2java
33
import org.gradle.api.DefaultTask
44
import org.gradle.api.tasks.TaskAction
55

6-
class CleanTask extends DefaultTask{
6+
class CleanTask extends DefaultTask {
77

88
@TaskAction
99
public void clean(){
10-
project.xsd2java.generatedWsdlDir.deleteDir()
10+
project.xsd2java.generatedXsdDir.deleteDir()
1111
}
1212
}

0 commit comments

Comments
 (0)