Skip to content

Commit

Permalink
bjornvester#8 Support multiple binding files
Browse files Browse the repository at this point in the history
  • Loading branch information
lkoe committed May 19, 2021
1 parent e1ba046 commit 52b5f97
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Here is a list of all available properties:
| wsdlDir | DirectoryProperty | "$projectDir/src<br>/main/resources" | The directory holding the WSDL and referenced XSD files to compile. |
| includes | ListProperty\<String> | \["**/*.wsdl"] | The inclusion filer (Ant style) for which WSDLs to include |
| generatedSourceDir | DirectoryProperty | "$buildDir/generated<br>/sources/wsdl2java/java" | The output directory for the generated Java sources.<br>Note that it will be deleted when running XJC. |
| bindingFile | RegularFileProperty | \[not set\] | A binding file to use in the schema compiler |
| bindingFiles | FileCollection | \[empty\] | Binding files to use in the schema compiler |
| cxfVersion | Provider\<String> | "3.4.3" | The version of CXF to use. |
| verbose | Provider\<Boolean> | true | Enables verbose output from CXF. |
| suppressGeneratedDate | Provider\<Boolean> | true | Suppresses generating dates in CXF. Default is true to support reproducible builds and to work with the build cache. |
Expand Down Expand Up @@ -90,11 +90,12 @@ wsdl2java {
Note that the directory will be wiped completely on each run, so don't put other source files in it.

### Configure binding files
A binding file can be added like this:
A binding file can be added like this, multiple binding files are supported:

```kotlin
wsdl2java {
bindingFile.set(layout.projectDirectory.file("src/main/bindings/binding.xjb"))
bindingFile("src/main/bindings/binding.xjb")
bindingFile("src/main/bindings/another-binding.xjb")
}
```

Expand All @@ -120,7 +121,7 @@ dependencies {
}

wsdl2java {
bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xjb"))
bindingFile("src/main/bindings/bindings.xjb")
}
```

Expand Down
2 changes: 1 addition & 1 deletion integration-test/bindings-datetime-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies {
}

wsdl2java {
bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xml"))
bindingFile("src/main/bindings/bindings.xml")
markGenerated.set("yes-jdk8")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.inject.Inject
open class Wsdl2JavaPluginExtension @Inject constructor(objects: ObjectFactory, layout: ProjectLayout) {
val wsdlDir = objects.directoryProperty().convention(layout.projectDirectory.dir("src/main/resources"))
val includes = objects.listProperty(String::class.java).convention(listOf("**/*.wsdl"))
val bindingFile = objects.fileProperty()
val bindingFiles = objects.fileCollection()
val generatedSourceDir = objects.directoryProperty().convention(layout.buildDirectory.dir("generated/sources/wsdl2java"))
val cxfVersion = objects.property(String::class.java).convention("3.4.3")
val options = objects.listProperty(String::class.java)
Expand All @@ -25,4 +25,14 @@ open class Wsdl2JavaPluginExtension @Inject constructor(objects: ObjectFactory,
@JvmStatic
val MARK_GENERATED_YES_JDK9 = "yes-jdk9"
}

/**
* Adds a binding file. The given path is evaluated as per [org.gradle.api.Project.file].
*
* @param path The binding file to add.
* @return this
*/
fun bindingFile(path: Any) {
bindingFiles.from(path)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ open class Wsdl2JavaTask @Inject constructor(
@get:Input
val includes = objects.listProperty(String::class.java).convention(getWsdl2JavaExtension().includes)

@get:InputFile
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
@Optional
val bindingFile = objects.fileProperty().convention(getWsdl2JavaExtension().bindingFile)
val bindingFiles = objects.fileCollection().from(getWsdl2JavaExtension().bindingFiles)

@get:Input
@Optional
Expand Down Expand Up @@ -157,11 +156,11 @@ open class Wsdl2JavaTask @Inject constructor(
defaultArgs.add("-verbose")
}

if (bindingFile.isPresent) {
bindingFiles.forEach {
defaultArgs.addAll(
listOf(
"-b",
bindingFile.get().asFile.absolutePath
it.absolutePath
)
)
}
Expand Down

0 comments on commit 52b5f97

Please sign in to comment.