ciscoo / cxf-codegen-gradle

Gradle plugin to generate Java artifacts from WSDL
Apache License 2.0
26 stars 6 forks source link

Setting language/locale for generated javadoc comments #20

Closed mikhail-timofeev closed 2 years ago

mikhail-timofeev commented 2 years ago

I could not find a way to specify the language used to generate javadoc comments in the generated classes and I think this would be a great feature to have. E.g. via a parameter 'locale' accepting java.util.Locale.

ciscoo commented 2 years ago

The plugin delegates to wsdl2java. The tool itself does not provide any option in relation to the language or locale as far as I can see, so this plugin does not either.

mikhail-timofeev commented 2 years ago

couldn't it be done like here? https://github.com/yupzip/wsdl2java/blob/0eef05c057fd799aeec59c9cf057793ad4c73743/src/main/groovy/com/yupzip/wsdl2java/Wsdl2JavaTask.groovy#L64

ciscoo commented 2 years ago

Oh, I see. That plugin programmatically invokes the wsdl2java tool directly. This plugin does not do that and instead delegates the invocation to Gradle via JavaExec:

As mentioned in the documentation, Wsdl2JavaTask is a subclass of JavaExec, so whatever you can do to JavaExec tasks you can do to Wsdl2JavaTask

From Googling, there are two ways to set the locale.

  1. Programmatically as that plugin you linked does.
  2. JVM arguments.

You should be able to do (2) with something like following:

import io.mateo.cxf.codegen.wsdl2java.Wsdl2JavaTask

plugins {
    id("java")
    id("io.mateo.cxf-codegen") version "1.0.0-rc.3"
}

repositories {
    mavenCentral()
}

cxfCodegen {
    wsdl2java {
        register("calculator") {
            wsdl.set(file("calculator.wsdl"))
        }
    }
}

tasks.named("wsdl2javaCalculator", Wsdl2JavaTask::class) {
    allJvmArgs = listOf("-Duser.language=fr", "-Duser.country=CA")
}

References:

mikhail-timofeev commented 2 years ago

will try that right away, thank you for your support and work!