diff --git a/README.md b/README.md index 42c402c..dedb7c7 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Here is a list of all available properties: | includes | ListProperty\ | \["**/*.wsdl"] | Inclusion filers (Ant style) for which WSDLs to include. | | includesWithOptions | Map\ | \[not set\] | Inclusion filters like above, but with individual options. See below. | | generatedSourceDir | DirectoryProperty | "$buildDir/generated
/sources/wsdl2java/java" | The output directory for the generated Java sources.
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\ | true | Set to use the `jakarta` namespace. If false, uses the `javax` namespace. This value also determines the default version of CXF. | | cxfVersion | Provider\ | "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\ | \[not set\] | Enables verbose output from CXF. If not set, it will be be enabled only on the info logging level. | @@ -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") } ``` @@ -202,7 +203,7 @@ dependencies { } wsdl2java { - bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xjb")) + bindingFile("src/main/bindings/bindings.xjb") } ``` diff --git a/integration-test/cxf3/bindings-datetime-test/build.gradle.kts b/integration-test/cxf3/bindings-datetime-test/build.gradle.kts index fa931ab..350bbab 100644 --- a/integration-test/cxf3/bindings-datetime-test/build.gradle.kts +++ b/integration-test/cxf3/bindings-datetime-test/build.gradle.kts @@ -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") } diff --git a/integration-test/cxf4/bindings-datetime-test-jakarta/build.gradle.kts b/integration-test/cxf4/bindings-datetime-test-jakarta/build.gradle.kts index b8b6dd0..9ab5fc4 100644 --- a/integration-test/cxf4/bindings-datetime-test-jakarta/build.gradle.kts +++ b/integration-test/cxf4/bindings-datetime-test-jakarta/build.gradle.kts @@ -8,5 +8,5 @@ dependencies { } wsdl2java { - bindingFile.set(layout.projectDirectory.file("src/main/bindings/bindings.xml")) + bindingFile("src/main/bindings/bindings.xml") } diff --git a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPlugin.kt b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPlugin.kt index 6d402de..7f87f11 100644 --- a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPlugin.kt +++ b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPlugin.kt @@ -73,7 +73,7 @@ class Wsdl2JavaPlugin : Plugin { 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) diff --git a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtension.kt b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtension.kt index d7e4e95..0437482 100644 --- a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtension.kt +++ b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtension.kt @@ -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) @@ -31,7 +31,7 @@ open class Wsdl2JavaPluginExtension @Inject constructor(objects: ObjectFactory, wsdlDir.convention(this@Wsdl2JavaPluginExtension.wsdlDir) includes.convention(this@Wsdl2JavaPluginExtension.includes) includesWithOptions.convention(this@Wsdl2JavaPluginExtension.includesWithOptions) - bindingFile.convention(this@Wsdl2JavaPluginExtension.bindingFile) + bindingFiles.from(this@Wsdl2JavaPluginExtension.bindingFiles) generatedSourceDir.convention(layout.buildDirectory.dir("generated/sources/wsdl2java-$name/java")) options.convention(this@Wsdl2JavaPluginExtension.options) verbose.convention(this@Wsdl2JavaPluginExtension.verbose) @@ -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) + } } diff --git a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtensionGroup.kt b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtensionGroup.kt index b85fe0d..9eab6b6 100644 --- a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtensionGroup.kt +++ b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaPluginExtensionGroup.kt @@ -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 @@ -11,7 +11,7 @@ interface Wsdl2JavaPluginExtensionGroup { val wsdlDir: DirectoryProperty val includes: ListProperty val includesWithOptions: MapProperty> - val bindingFile: RegularFileProperty + val bindingFiles: ConfigurableFileCollection val generatedSourceDir: DirectoryProperty val options: ListProperty val verbose: Property diff --git a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaTask.kt b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaTask.kt index 0dcda0e..ce5f0ed 100644 --- a/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaTask.kt +++ b/src/main/kotlin/com/github/bjornvester/wsdl2java/Wsdl2JavaTask.kt @@ -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 @@ -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 ) ) }