Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#8 Support multiple binding files #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Here is a list of all available properties:
| includes | ListProperty\<String> | \["**/*.wsdl"] | Inclusion filers (Ant style) for which WSDLs to include. |
| includesWithOptions | Map\<String, List> | \[not set\] | Inclusion filters like above, but with individual options. See below. |
| 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. |
| useJakarta | Provider\<Boolean> | true | Set to use the `jakarta` namespace. If false, uses the `javax` namespace. This value also determines the default version of CXF. |
| cxfVersion | Provider\<String> | "4.0.2" for jakarta / 3.5.6 for javax | The version of CXF to use. Use a version >= 4 for `jakarta` and below for `javax`. |
| verbose | Provider\<Boolean> | \[not set\] | Enables verbose output from CXF. If not set, it will be be enabled only on the info logging level. |
Expand Down Expand Up @@ -168,11 +168,12 @@ Note that the directory will be wiped completely on each run, so don't put other

### 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 Down Expand Up @@ -202,7 +203,7 @@ dependencies {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ dependencies {
}

wsdl2java {
bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xml"))
useJakarta.set(false)
bindingFile("src/main/bindings/bindings.xml")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ dependencies {
}

wsdl2java {
bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xml"))
bindingFile("src/main/bindings/bindings.xml")
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Wsdl2JavaPlugin : Plugin<Project> {
wsdlInputDir.convention(group.wsdlDir)
includes.convention(group.includes)
includesWithOptions.convention(group.includesWithOptions)
bindingFile.convention(group.bindingFile)
bindingFiles.from(group.bindingFiles)
options.convention(group.options)
verbose.convention(group.verbose)
suppressGeneratedDate.convention(group.suppressGeneratedDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open class Wsdl2JavaPluginExtension @Inject constructor(objects: ObjectFactory,
override val wsdlDir = objects.directoryProperty().convention(layout.projectDirectory.dir("src/main/resources"))
override val includes = objects.listProperty(String::class.java).convention(listOf("**/*.wsdl"))
override val includesWithOptions = objects.mapProperty(String::class.java, List::class.java)
override val bindingFile = objects.fileProperty()
override val bindingFiles = objects.fileCollection()
override val generatedSourceDir = objects.directoryProperty().convention(layout.buildDirectory.dir("generated/sources/wsdl2java/java"))
override val options = objects.listProperty(String::class.java)
override val verbose = objects.property(Boolean::class.java)
Expand All @@ -31,7 +31,7 @@ open class Wsdl2JavaPluginExtension @Inject constructor(objects: ObjectFactory,
wsdlDir.convention([email protected])
includes.convention([email protected])
includesWithOptions.convention([email protected])
bindingFile.convention(this@Wsdl2JavaPluginExtension.bindingFile)
bindingFiles.from(this@Wsdl2JavaPluginExtension.bindingFiles)
generatedSourceDir.convention(layout.buildDirectory.dir("generated/sources/wsdl2java-$name/java"))
options.convention([email protected])
verbose.convention([email protected])
Expand All @@ -55,4 +55,14 @@ open class Wsdl2JavaPluginExtension @Inject constructor(objects: ObjectFactory,
@JvmStatic
val GENERATED_STYLE_JAKARTA = "jakarta"
}

/**
* 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
@@ -1,7 +1,7 @@
package com.github.bjornvester.wsdl2java

import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
Expand All @@ -11,7 +11,7 @@ interface Wsdl2JavaPluginExtensionGroup {
val wsdlDir: DirectoryProperty
val includes: ListProperty<String>
val includesWithOptions: MapProperty<String, List<*>>
val bindingFile: RegularFileProperty
val bindingFiles: ConfigurableFileCollection
val generatedSourceDir: DirectoryProperty
val options: ListProperty<String>
val verbose: Property<Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ abstract class Wsdl2JavaTask @Inject constructor(
@get:Input
val includesWithOptions = objects.mapProperty(String::class.java, List::class.java).convention(getWsdl2JavaExtension().includesWithOptions)

@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 @@ -193,11 +192,11 @@ abstract class Wsdl2JavaTask @Inject constructor(
defaultArgs.add("-verbose")
}

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