Skip to content

Commit ea79571

Browse files
committed
Added task information to the wsdl2java Java sourceset directory
This hooks up task dependencies to things like sourcesJar automatically.
1 parent 19fe642 commit ea79571

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ xjc {
3939

4040
Here is a list of all available properties:
4141

42-
| Property | Type | Default | Description |
43-
|----------------------------|----------------------------|--------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
44-
| xsdDir | DirectoryProperty | "$projectDir/src<br>/main/resources" | The directory holding the xsd files to compile. |
45-
| includes | ListProperty\<String> | \[empty\] | An optional include pattern for the files in the xsdDir property |
46-
| excludes | ListProperty\<String> | \[empty\] | An optional exclude pattern for the files in the xsdDir property |
47-
| bindingFiles | ConfigurableFileCollection | xsdDir.asFileTree.matching<br> { include("**/*.xjb") } | The binding files to use in the schema compiler |
48-
| outputJavaDir | DirectoryProperty | "$buildDir/generated<br>/sources/xjc/java" | The output directory for the generated Java sources.<br>Note that it will be deleted when running XJC. |
49-
| outputResourcesDir | DirectoryProperty | "$buildDir/generated<br>/sources/xjc/resources" | The output directory for the generated resources (if any).<br>Note that it will be deleted when running XJC. |
50-
| useJakarta | Provider\<Boolean> | true | Set to use the `jakarta` namespace. If false, uses the `javax` namespace. This value determines the default version of XJC and the JAXB binding provider. |
51-
| xjcVersion | Provider\<String> | "3.0.2" for jakarta /<br> "2.3.8" for javax | The version of XJC to use. |
52-
| defaultPackage | Provider\<String> | \[not set\] | The default package for the generated Java classes.<br>If empty, XJC will infer it from the namespace. |
53-
| generateEpisode | Provider\<Boolean> | false | If true, generates an Episode file for the generated Java classes. |
54-
| markGenerated | Provider\<Boolean> | false | If true, marks the generated code with the annotation `@javax.annotation.Generated`. |
55-
| options | ListProperty\<String> | \[empty\] | Options to pass to either the XJC core, or to third party plugins in the `xjcPlugins` configuration |
56-
| groups | NamedDomainObjectContainer | \[empty\] | Allows you to group a set of XSDs and generate sources with different configurations. Requires Gradle 7.0 or higher. See below for details. |
57-
| addCompilationDependencies | Provider\<Boolean> | true | Adds dependencies to the `implementation` configuration for compiling the generated sources. These includes `jakarta.xml.bind:jakarta.xml.bind-api` and possibly `jakarta.annotation:jakarta.annotation-api`. |
42+
| Property | Type | Default | Description |
43+
|----------------------------|---------------------------------|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
44+
| xsdDir | DirectoryProperty | "$projectDir/src<br>/main/resources" | The directory holding the xsd files to compile. |
45+
| includes | ListProperty\<String> | \[empty\] | An optional include pattern for the files in the xsdDir property |
46+
| excludes | ListProperty\<String> | \[empty\] | An optional exclude pattern for the files in the xsdDir property |
47+
| bindingFiles | ConfigurableFile-<br>Collection | xsdDir.asFileTree<br>.matching<br>{ include("**/*.xjb") } | The binding files to use in the schema compiler |
48+
| outputJavaDir | DirectoryProperty | "$buildDir/generated<br>/sources/xjc/java" | The output directory for the generated Java sources.<br>Note that it will be deleted when running XJC. |
49+
| outputResourcesDir | DirectoryProperty | "$buildDir/generated<br>/sources/xjc/resources" | The output directory for the generated resources (if any).<br>Note that it will be deleted when running XJC. |
50+
| useJakarta | Provider\<Boolean> | true | Set to use the `jakarta` namespace. If false, uses the `javax` namespace. This value determines the default version of XJC and the JAXB binding provider. |
51+
| xjcVersion | Provider\<String> | "3.0.2" for jakarta /<br> "2.3.8" for javax | The version of XJC to use. |
52+
| defaultPackage | Provider\<String> | \[not set\] | The default package for the generated Java classes.<br>If empty, XJC will infer it from the namespace. |
53+
| generateEpisode | Provider\<Boolean> | false | If true, generates an Episode file for the generated Java classes. |
54+
| markGenerated | Provider\<Boolean> | false | If true, marks the generated code with the annotation `@javax.annotation.Generated`. |
55+
| options | ListProperty\<String> | \[empty\] | Options to pass to either the XJC core, or to third party plugins in the `xjcPlugins` configuration |
56+
| groups | NamedDomainObject-<br>Container | \[empty\] | Allows you to group a set of XSDs and generate sources with different configurations. Requires Gradle 7.0 or higher. See below for details. |
57+
| addCompilationDependencies | Provider\<Boolean> | true | Adds dependencies to the `implementation` configuration for compiling the generated sources. These includes `jakarta.xml.bind:jakarta.xml.bind-api` and possibly `jakarta.annotation:jakarta.annotation-api`. |
5858

5959
### Choosing which schemas to generate source code for
6060

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "com.github.bjornvester"
8-
version = "1.8.1"
8+
version = "1.8.2"
99

1010
repositories {
1111
mavenCentral()
@@ -45,7 +45,7 @@ gradlePlugin {
4545
displayName = "Gradle XJC plugin"
4646
tags.set(listOf("xjc", "jaxb", "xsd"))
4747
description = """Changes:
48-
|- Fixed another issue with custom location of binding files.""".trimMargin()
48+
|- Fixed a missing task dependency to xsd from sourcesJar.""".trimMargin()
4949
}
5050
}
5151
}

integration-test/test-producer-3x/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ xjc {
1111
generateEpisode.set(true)
1212
includes.set(listOf("MySchemaWithFunnyChar.xsd"))
1313
}
14+
15+
java {
16+
withSourcesJar()
17+
}

src/main/kotlin/com/github/bjornvester/xjc/XjcPlugin.kt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,12 @@ class XjcPlugin : Plugin<Project> {
8282
xjcBindConfiguration.from(project.configurations.named(XJC_BIND_CONFIGURATION_NAME))
8383
xjcPluginsConfiguration.from(project.configurations.named(XJC_PLUGINS_CONFIGURATION_NAME))
8484
bindingFiles.setFrom(group.bindingFiles)
85-
86-
val sourceSets = project.properties["sourceSets"] as SourceSetContainer
87-
88-
sourceSets.named(MAIN_SOURCE_SET_NAME) {
89-
java.srcDir(outputJavaDir)
90-
resources.srcDir(outputResourcesDir)
91-
}
92-
}
93-
94-
project.tasks.named(JavaPlugin.PROCESS_RESOURCES_TASK_NAME) {
95-
dependsOn(task)
9685
}
9786

98-
project.tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME) {
99-
dependsOn(task)
87+
val sourceSets = project.properties["sourceSets"] as SourceSetContainer
88+
sourceSets.named(MAIN_SOURCE_SET_NAME) {
89+
java.srcDir(task.map { it.outputJavaDir })
90+
resources.srcDir(task.map { it.outputResourcesDir })
10091
}
10192

10293
return task

0 commit comments

Comments
 (0)