Upgrade XJC processing to com.github.bjornvester.xjc

This commit upgrades our build to use a different plugin for XJC
processing, so that Gradle doesn't output a compatibility warning
anymore.

Unfortunately, com.github.bjornvester.xjc only works against main
sources and our schema is only used for test purposes. This commit
therefore reconfigure the task to remove the xjc main source set and
apply it to the test source set instead.

Closes gh-33264
This commit is contained in:
Stéphane Nicoll 2024-07-23 15:24:30 +02:00
parent 656d08f075
commit 12b996b07d
1 changed files with 16 additions and 8 deletions

View File

@ -1,17 +1,12 @@
plugins {
id "org.unbroken-dome.xjc"
id "com.github.bjornvester.xjc" version "1.8.2"
}
description = "Spring Object/XML Marshalling"
xjc {
xjcVersion = '3.0'
}
sourceSets {
test {
xjcTargetPackage = 'org.springframework.oxm.jaxb.test'
}
xsdDir.set(layout.projectDirectory.dir("src/test/schema"))
defaultPackage.set('org.springframework.oxm.jaxb.test')
}
dependencies {
@ -31,3 +26,16 @@ dependencies {
testRuntimeOnly("com.sun.xml.bind:jaxb-core")
testRuntimeOnly("com.sun.xml.bind:jaxb-impl")
}
tasks.named("xjc").configure { xjc ->
// XJC plugin only works against main sources
def javaSrcDirs = sourceSets.main.java.srcDirs
javaSrcDirs.remove(file(xjc.outputJavaDir))
sourceSets.main.java.srcDirs = javaSrcDirs
def resourcesSrcDirs = sourceSets.main.resources.srcDirs
resourcesSrcDirs.remove(file(xjc.outputResourcesDir))
sourceSets.main.resources.srcDirs = resourcesSrcDirs
sourceSets.test.java.srcDir(xjc.outputJavaDir)
sourceSets.test.resources.srcDir(xjc.outputResourcesDir)
}