Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace xjc with custom XSD Java code gen #1464

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,42 @@ coverage
gen
.kotlin


/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# env files (can opt-in for commiting if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

1 change: 1 addition & 0 deletions Src/java/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies {
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.2")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("com.github.node-gradle:gradle-node-plugin:7.1.0")
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
api("codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0")
}

var buildDir = project.layout.buildDirectory.get().toString()
val buildDir = project.layout.buildDirectory.get().toString()
val destDir = "${buildDir}/generated/sources/$name/main/java"

tasks.withType<KotlinCompile>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
}

val xjc: Configuration by configurations.creating

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:2.0.13")
xjc("org.apache.ant:ant:1.10.14")
}

var buildDir = project.layout.buildDirectory.get().toString()
val destDir = "${buildDir}/generated/sources/$name/main/java"

tasks.withType<KotlinCompile>().configureEach {
dependsOn(tasks.withType<XjcTask>())
}

tasks.withType<JavaCompile>().configureEach {
dependsOn(tasks.withType<XjcTask>())
}

tasks.withType<XjcTask>().configureEach {
outputDir = destDir
outputs.dir(outputDir)
}

tasks.withType<Delete>().configureEach {
delete(destDir)
}

sourceSets {
main {
java {
srcDir(destDir)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.gradle.node.task.NodeTask
import com.github.gradle.node.npm.task.NpmInstallTask

plugins {
id("cql.library-conventions")
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 {
download = true
nodeProjectDir = file("../../js/xsd-java-gen")
}

val buildDir = project.layout.buildDirectory.get().toString()
val destDir = "${buildDir}/generated/sources/$name/main/java"

tasks.register<NodeTask>("runXsdJavaGen") {
dependsOn(tasks.withType<NpmInstallTask>())
script = file("../../js/xsd-java-gen/generate.js")
}

tasks.withType<KotlinCompile>().configureEach {
dependsOn(tasks.withType<NodeTask>())
}

tasks.withType<JavaCompile>().configureEach {
dependsOn(tasks.withType<NodeTask>())
}

//tasks.withType<NodeTask>().configureEach {
// outputDir = destDir
// outputs.dir(outputDir)
//}

tasks.withType<Delete>().configureEach {
delete(destDir)
}

sourceSets {
main {
java {
srcDir(destDir)
}
}
}
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.kts
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.kts
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")
}

tasks.register<XjcTask>("generateModel") {
Expand Down
40 changes: 0 additions & 40 deletions Src/js/cql-ui/.gitignore

This file was deleted.

Loading
Loading