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

[6.2]feat: bump jaxb to 4 and dynamic generate code #1128

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
11 changes: 4 additions & 7 deletions aligner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ dependencies {
if (providedModuleLibsDir.directory) {
compileOnly fileTree(dir: providedCoreLibsDir, includes: ['**/commons-*.jar', '**/lib-mnemonics*.jar',
'**/slf4j*.jar', '**/supertmxmerge-*.jar', '**/jaxb-api*.jar'])
compileOnly fileTree(dir: providedModuleLibsDir, includes: ['**/maligna-*.jar'])
implementation fileTree(dir: providedModuleLibsDir, includes: ['**/maligna-*.jar'])
} else {
// Aligner
implementation(libs.loomchild.maligna) {
exclude module: 'jaxb-api'
exclude module: 'jaxb-core'
exclude module: 'jaxb-runtime'
}
compileOnly(libs.jaxb.api)
implementation(libs.tokyo.northside.maligna)
compileOnly(libs.jaxb4.api)
compileOnly(libs.jaxb4.runtime)
compileOnly(libs.madlonkay.supertmxmerge)
compileOnly(libs.omegat.mnemonics)
compileOnly(libs.commons.io)
Expand Down
72 changes: 50 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ext {
}
def omtFlavor = omtVersion.beta.empty ? 'standard' : 'latest'
def omtWebsite = 'https://omegat.org'
def xjcOutputDir = 'generated/xjc/main/'

version = omtVersion.version + getUpdateSuffix(omtVersion.update)

Expand Down Expand Up @@ -197,7 +198,8 @@ allprojects {
sourceSets {
main {
java {
srcDir 'src'
srcDir layout.buildDirectory.dir(xjcOutputDir)
srcDir'src'
}
resources {
srcDir 'src'
Expand Down Expand Up @@ -260,9 +262,9 @@ dependencies {
runtimeOnly(libs.slf4j.jdk14)

// jaxb gen compilation
implementation(libs.jaxb.api)
runtimeOnly(libs.jaxb.core)
runtimeOnly(libs.jaxb.runtime)
implementation(libs.jaxb4.api)
runtimeOnly(libs.jaxb4.core)
runtimeOnly(libs.jaxb4.runtime)

// macOS integration
implementation(libs.madlonkay.desktopsupport)
Expand Down Expand Up @@ -376,7 +378,9 @@ dependencies {
testRuntimeOnly(libs.slf4j.jdk14)

// JAXB codegen only
jaxb(libs.jaxb.xjc)
jaxb(libs.jaxb4.xjc)
jaxb(libs.jaxb4.api)
jaxb(libs.jaxb4.runtime)

// genMac only
genMac(libs.omegat.appbundler)
Expand Down Expand Up @@ -1448,31 +1452,34 @@ tasks.register('checksums') {
}
}

tasks.register('genJAXB') {
description = 'Generate classes for loading and manipulating XML formats'
tasks.register('createXjcOutputDir') {
mkdir(layout.buildDirectory.dir(xjcOutputDir))
}

ext.makeJaxbTask = { args ->
def taskName = "gen${args.name.capitalize()}"
tasks.register(taskName, JavaExec) {
dependsOn createXjcOutputDir
classpath = configurations.jaxb
mainClass = 'com.sun.tools.xjc.XJCFacade'
delegate.args args.args
outputs.dir args.outdir
outputs.dir layout.buildDirectory.dir(xjcOutputDir + args.outdir)
jvmArguments = ["-Duser.language=en"]
}
genJAXB.dependsOn taskName
compileJava.dependsOn taskName
sourcesJar.dependsOn taskName
}

makeJaxbTask(name: 'segmentation', outdir: 'src/gen/core/segmentation',
args: ['-no-header', '-d', 'src', '-p', 'gen.core.segmentation', 'src/schemas/srx20.xsd'])
makeJaxbTask(name: 'filters', outdir: 'src/gen/core/filters',
args: ['-no-header', '-d', 'src', '-p', 'gen.core.filters', 'src/schemas/filters.xsd'])
makeJaxbTask(name: 'tbx', outdir: 'src/gen/core/tbx',
args: ['-no-header', '-d', 'src', '-p', 'gen.core.tbx', 'src/schemas/tbx.xsd'])
makeJaxbTask(name: 'project', outdir: 'src/gen/core/project',
args: ['-no-header', '-d', 'src', '-p', 'gen.core.project', 'src/schemas/project_properties.xsd'])
makeJaxbTask(name: 'tmx14', outdir: 'src/gen/core/tmx14',
args: ['-no-header', '-d', 'src', '-p', 'gen.core.tmx14', '-b', 'src/schemas/tmx14.xjb', 'src/schemas/tmx14.xsd'])
makeJaxbTask(name: 'segmentation', outdir: 'gen/core/segmentation',
args: ['-no-header', '-d', "$buildDir/" + xjcOutputDir, '-p', 'gen.core.segmentation', 'src/schemas/srx20.xsd'])
makeJaxbTask(name: 'filters', outdir: 'gen/core/filters',
args: ['-no-header', '-d', "$buildDir/" + xjcOutputDir, '-p', 'gen.core.filters', 'src/schemas/filters.xsd'])
makeJaxbTask(name: 'tbx', outdir: 'gen/core/tbx',
args: ['-no-header', '-d', "$buildDir/" + xjcOutputDir, '-p', 'gen.core.tbx', 'src/schemas/tbx.xsd'])
makeJaxbTask(name: 'project', outdir: 'gen/core/project',
args: ['-no-header', '-d', "$buildDir/" + xjcOutputDir, '-p', 'gen.core.project', 'src/schemas/project_properties.xsd'])
makeJaxbTask(name: 'tmx14', outdir: 'gen/core/tmx14',
args: ['-no-header', '-d', "$buildDir/" + xjcOutputDir, '-p', 'gen.core.tmx14', '-b', 'src/schemas/tmx14.xjb', 'src/schemas/tmx14.xsd'])

tasks.register('changedOnBranch') {
description = 'List files that have been modified on this git branch.'
Expand Down Expand Up @@ -1553,6 +1560,9 @@ tasks.register('debug', JavaExec) {
classpath = sourceSets.main.runtimeClasspath
jvmArgs(["--illegal-access=warn"])
debug true
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('runOnJava17', JavaExec) {
Expand All @@ -1565,6 +1575,9 @@ tasks.register('runOnJava17', JavaExec) {
classpath = sourceSets.main.runtimeClasspath
jvmArgs(["--add-opens", "java.desktop/sun.awt.X11=ALL-UNNAMED"])
group = 'application'
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('runOnJava21', JavaExec) {
Expand All @@ -1577,6 +1590,9 @@ tasks.register('runOnJava21', JavaExec) {
classpath = sourceSets.main.runtimeClasspath
jvmArgs(["--add-opens", "java.desktop/sun.awt.X11=ALL-UNNAMED"])
group = 'application'
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

// E.g. when doing `build`, run checks before making distfiles
Expand All @@ -1587,6 +1603,9 @@ test {
if (project.hasProperty('headless')) {
systemProperty 'java.awt.headless', 'true'
}
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('testIntegration', JavaExec) {
Expand All @@ -1599,6 +1618,9 @@ tasks.register('testIntegration', JavaExec) {
mainClass = 'org.omegat.core.data.TestTeamIntegration'
classpath = sourceSets.testIntegration.runtimeClasspath
systemProperties = System.properties
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('testOnJava17', Test) {
Expand All @@ -1611,6 +1633,9 @@ tasks.register('testOnJava17', Test) {
systemProperty 'java.awt.headless', 'true'
}
group = 'verification'
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('testOnJava21', Test) {
Expand All @@ -1623,6 +1648,9 @@ tasks.register('testOnJava21', Test) {
systemProperty 'java.awt.headless', 'true'
}
group = 'verification'
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('testAcceptance', Test) {
Expand All @@ -1638,6 +1666,9 @@ tasks.register('testAcceptance', Test) {
classpath = sourceSets.testAcceptance.runtimeClasspath
systemProperties = System.properties
shouldRunAfter(tasks.test)
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

ext.mavenStyleVersion = version.replace('_', '-')
Expand Down Expand Up @@ -1753,9 +1784,6 @@ tasks.withType(JavaExec).configureEach {
// Allow setting the max heap size for the run task from the command line, e.g.
// `gradle -PrunMaxHeapSize=1024M run`
maxHeapSize = findProperty('runMaxHeapSize')
// Ask modules to be up-to-date before run task executed
dependsOn subprojects.tasks.jar
dependsOn firstSteps
}

tasks.register('printVersion') {
Expand Down
19 changes: 10 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,22 @@ gnudiff = "1.15"
desktopsupport = "0.6.0"
protocolhandler = "0.1.4"
pdfbox = "3.0.3"
maligna = "3.0.1"
maligna = "4.0.0"
trie4j = "0.9.10_1"
dsl4j = "1.0.0"
stardict4j = "1.1.0"
juniversalchardet = "2.5.0"
mnemonics = "1.2"
hunspell = "2.1.2"
xjc = "2.3.9"
xjc = "4.0.5"
jaxb4_api = "4.0.2"
jaxb = "4.0.5"
jna = "5.13.0"
jfa = "1.2.0"
tipoftheday = "0.4.4"
flatlaf="3.5.1"
assertj_swing_junit = "4.0.0-beta-2"
morfologik = "2.1.9"
jaxb = "2.3.0"

[libraries]
slf4j-api = {group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j"}
Expand Down Expand Up @@ -118,7 +119,7 @@ ivy = {group = "org.apache.ivy", name = "ivy", version.ref = "ivy"}
jackson-core = {group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson"}
jackson-databind = {group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson"}
jackson-xml = {group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-xml", version.ref = "jackson"}
jackson-jaxb = {group = "com.fasterxml.jackson.module", name = "jackson-module-jaxb-annotations", version.ref = "jackson"}
jackson-jaxb = {group = "com.fasterxml.jackson.module", name = "jackson-module-jakarta-xmlbind-annotations", version.ref = "jackson"}
jackson-yaml = {group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-yaml", version.ref = "jackson"}
jgit = {group = "org.eclipse.jgit", name = "org.eclipse.jgit", version.ref = "jgit"}
jgit-ssh = {group = "org.eclipse.jgit", name = "org.eclipse.jgit.ssh.apache", version.ref = "jgit"}
Expand Down Expand Up @@ -150,17 +151,17 @@ omegat-gnudiff4j = {group = "org.omegat", name = "gnudiff4j", version.ref = "gnu
madlonkay-desktopsupport = {group = "org.madlonkay", name = "desktopsupport", version.ref = "desktopsupport"}
url-protocol-handler = {group = "tokyo.northside", name = "url-protocol-handler", version.ref = "protocolhandler"}
apache-pdfbox = {group = "org.apache.pdfbox", name = "pdfbox", version.ref = "pdfbox"}
loomchild-maligna = {group = "net.loomchild", name = "maligna", version.ref = "maligna"}
tokyo-northside-maligna = {group = "tokyo.northside", name = "maligna", version.ref = "maligna"}
trie4j = {group = "tokyo.northside", name = "trie4j", version.ref = "trie4j"}
dsl4j = {group = "tokyo.northside", name = "dsl4j", version.ref = "dsl4j"}
stardict4j = {group = "tokyo.northside", name = "stardict4j", version.ref = "stardict4j"}
juniversal-chardet = {group = "com.github.albfernandez", name = "juniversalchardet", version.ref = "juniversalchardet"}
omegat-mnemonics = {group = "org.omegat", name = "lib-mnemonics", version.ref = "mnemonics"}
dumont-hunspell = {group = "com.gitlab.dumonts", name = "hunspell", version.ref = "hunspell"}
jaxb-api = {group = "javax.xml.bind", name = "jaxb-api", version.ref = "jaxb"}
jaxb-xjc = {group = "org.glassfish.jaxb", name = "jaxb-xjc", version.ref = "xjc"}
jaxb-core = {group = "org.glassfish.jaxb", name = "jaxb-core", version.ref = "jaxb"}
jaxb-runtime = {group = "org.glassfish.jaxb", name = "jaxb-runtime", version.ref = "jaxb"}
jaxb4-api = {group = "jakarta.xml.bind", name = "jakarta.xml.bind-api", version = "jaxb4_api"}
jaxb4-xjc = {group = "org.glassfish.jaxb", name = "jaxb-xjc", version.ref = "xjc"}
jaxb4-core = {group = "org.glassfish.jaxb", name = "jaxb-core", version.ref = "jaxb"}
jaxb4-runtime = {group = "org.glassfish.jaxb", name = "jaxb-runtime", version.ref = "jaxb"}
tipoftheday = {group = "tokyo.northside", name = "tipoftheday", version.ref = "tipoftheday"}
jna = {group = "net.java.dev.jna", name = "jna-platform", version.ref = "jna"}
jfa = {group = "de.jangassen", name = "jfa", version.ref = "jfa"}
Expand Down
Loading
Loading