import com.github.bjornvester.xjc.XjcTask plugins { id "com.github.bjornvester.xjc" } description = "Spring Object/XML Marshalling" xjc { xsdDir.set(layout.projectDirectory.dir("src/test/schema")) defaultPackage.set('org.springframework.oxm.jaxb.test') } dependencies { api(project(":spring-beans")) api(project(":spring-core")) optional("com.thoughtworks.xstream:xstream") optional("jakarta.activation:jakarta.activation-api") optional("jakarta.xml.bind:jakarta.xml.bind-api") testImplementation(project(":spring-context")) testImplementation(testFixtures(project(":spring-core"))) testImplementation("org.codehaus.jettison:jettison") { exclude group: "stax", module: "stax-api" } testImplementation("org.xmlunit:xmlunit-assertj") testImplementation("org.xmlunit:xmlunit-matchers") testRuntimeOnly("com.sun.xml.bind:jaxb-core") testRuntimeOnly("com.sun.xml.bind:jaxb-impl") } // The XJC plugin adds generated code to the main source set, but we need it only for tests. // 1) Reset main source sets to the standard directories only. sourceSets.main.java.setSrcDirs(["src/main/java"]) sourceSets.main.resources.setSrcDirs(["src/main/resources"]) // 2) Attach XJC output only to the test source sets via lazy providers. sourceSets.test.java.srcDir(tasks.named("xjc", XjcTask).flatMap { it.outputJavaDir }) sourceSets.test.resources.srcDir(tasks.named("xjc", XjcTask).flatMap { it.outputResourcesDir })