Open henning-meinhardt opened 10 months ago
Hi, any suggestion for a workaround for this?
Hey Henning,
I fixed this issue by simply putting the following option into my gradle build script:
xjc {
/* This option makes sure generated javadoc is in english
* as opposed to the locale of the current system. */
options.add("-Duser.language=en")
// ...
}
Worked like a charm.
Hi @wursthos , sorry for my late reply. I already tried that before and just did so again. It does not seem to work for me. The setting does not afffect the language of generated JavaDoc comments ;-( I'm using the latest version of the xjc-gradle-plugin and have the following defined in my gradle script:
xjc {
String schemaPath = "webapp/WEB-INF/schema"
xsdDir = layout.projectDirectory.dir (schemaPath)
includes = [ "xxxxx.xsd" ]
bindingFiles.setFrom (xsdDir.asFileTree.matching { include ("xxxxx.xjb") })
outputJavaDir = file (generatedSourcesDir)
useJakarta = true
addCompilationDependencies = true
options.add ("-Duser.language=es")
options.add ("-Xannotate")
options.add ("-Xfluent-api")
options.add ("-Xcopyable")
}
The output does not change when adjusting the language. I made sure that the gradle task is not cached.
Are you sure to use the same plugin an I do and not jaxb2-maven-plugin which has dedicated support for the "-Duser.language" parameter (https://github.com/mojohaus/jaxb2-maven-plugin/issues/9)?
Hey @henning-meinhardt, you are right. I must have simultaneously changed my system locale and wrongly attributed the language change to the xjc option. Sorry about the confusion.
However, I found (and properly tested) a solution that actually works well enough for me.
I just added this line to my gradle.properties
file:
org.gradle.jvmargs=-Duser.language=en -Duser.country=EN -Dfile.encoding=UTF-8
For the code to be regenerated in this language I had to run the clean task as well (./gradlew clean xjc
).
Hi, i'm missing an option to specify the language code or locale to use when invoking XJC. The current behavior is that environment variable LANG decides which language is selected for generating the JavaDoc comments in the generated files. I would like to have this reproducible, so I'd like a way to define the language on my own.
You currently use
// Set encoding (work-around for https://github.com/gradle/gradle/issues/13843) forkOptions.environment("LANG", System.getenv("LANG") ?: "C.UTF-8")
which basically passes the LANG envionment variable down to the XJC worker. But unfortunately LANG is nothing you can control from within a gradle build script or the gradle.properties file. The environment variable can only be set outside of the gradle script, i.e. its value depends on the environment found when the script runs.My suggestion is to provide a "language" or "locale" option in the XJCExtension that is honored in the forkOptions code above.
I'm using Gradle 8.5 by the way.
Kind regards Henning