Skip to content

Commit

Permalink
XSD Java code gen WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
antvaset committed Dec 6, 2024
1 parent 6a07897 commit a8cf790
Show file tree
Hide file tree
Showing 10 changed files with 774 additions and 3 deletions.
1 change: 1 addition & 0 deletions Src/java/buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ dependencies {
implementation 'ru.vyarus:gradle-animalsniffer-plugin:1.7.0'
implementation 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14'
implementation 'com.diffplug.spotless:spotless-plugin-gradle:6.23.3'
implementation 'com.github.node-gradle:gradle-node-plugin:7.1.0'
}
55 changes: 55 additions & 0 deletions Src/java/buildSrc/src/main/groovy/cql.xjc-temp-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
plugins {
id 'java'
}

configurations {
xjc
}

dependencies {
xjc 'codes.rafael.jaxb2_commons:jaxb2-basics-ant:3.0.0'
xjc 'codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0'
xjc 'codes.rafael.jaxb2_commons:jaxb2-fluent-api:3.0.0'
// Eclipse has taken over all Java EE reference components
// https://www.infoworld.com/article/3310042/eclipse-takes-over-all-java-ee-reference-components.html
// https://wiki.eclipse.org/Jakarta_EE_Maven_Coordinates
xjc 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.1'
xjc 'org.glassfish.jaxb:jaxb-xjc:3.0.2'
xjc 'org.glassfish.jaxb:jaxb-runtime:4.0.3'
xjc 'org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2'
xjc 'org.slf4j:slf4j-simple:1.7.36'
}

ext.xjc = [
destDir: "${buildDir}/generated/sources/$name-xjc-temp/main/java",
args: '-disableXmlSecurity -Xfluent-api -Xequals -XhashCode -XtoString -Xsetters -Xsetters-mode=direct'
]


task generateSources {

outputs.dir xjc.destDir

doLast {
file(xjc.destDir).mkdirs()

ant.taskdef(name: 'xjc', classname: 'org.jvnet.jaxb2_commons.xjc.XJC2Task', classpath: configurations.xjc.asPath)

/* The above sets up the task, but the real work of the task should be specified in the subproject using
generateSources.doLast. For example:
generateSources.doLast {
ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/path/to/file.xsd") {
arg(line: xjc.args)
}
}
*/
}
}

compileJava {
dependsOn generateSources
}

clean {
delete xjc.destDir
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
plugins {
id "com.github.node-gradle.node"
}

dependencies {
api 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.1'
api 'codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0'
}

node {
nodeProjectDir = file('../../js/xsd-java-gen')
}

var outDir = "${buildDir}/generated/sources/$name/main/java"

task runXsdJavaGen(type: NodeTask) {
dependsOn npmInstall
script = file('../../js/xsd-java-gen/generate.js')
}

compileJava {
dependsOn runXsdJavaGen
}

sourcesJar {
dependsOn runXsdJavaGen
}

sourceSets {
main {
java {
srcDir(outDir)
}
}
}

clean {
delete outDir
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void removeChoiceTypeSpecifierTypeIfEmpty() {

private static class ExtChoiceTypeSpecifier extends ChoiceTypeSpecifier {
public List<TypeSpecifier> getType() {
return type;
return _type;
}
}
}
3 changes: 2 additions & 1 deletion Src/java/elm/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'cql.library-conventions'
id 'cql.xjc-conventions'
id 'cql.xjc-temp-conventions'
id 'cql.xsd-java-gen-conventions'
}

dependencies {
Expand Down
3 changes: 2 additions & 1 deletion Src/java/model/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'cql.library-conventions'
id 'cql.xjc-conventions'
id 'cql.xjc-temp-conventions'
id 'cql.xsd-java-gen-conventions'
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions Src/js/xsd-java-gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Loading

0 comments on commit a8cf790

Please sign in to comment.