Как я могу запустить задачу wsgen ant в Kotlin dsl? - PullRequest
0 голосов
/ 16 мая 2019

Я конвертирую существующее задание на основе Groovy в kotlin, следующий подход мучительно медленный.Есть ли альтернативный подход к тому, что у меня есть?

tasks.register("generateWsdls") {
    dependsOn("someJavaCompileTask")
    description = "Runs wsgen on endpoint classes."
    group = "Source Generation"

    val destinationDir = "$projectDir/output/service"
    val classesDir = "$projectDir/build/classes/main"
    val classesRelativePath = "api/classes"
    val wsdlsToGenerate = fileTree(classesRelativePath) {include("**/*_api.class")}
    val taskCp = sourceSets.getAt("main").runtimeClasspath.asPath
    val cp = (sourceSets.getAt("main").runtimeClasspath + files(classesRelativePath) + files("api/java")).asPath

    outputs.dir(destinationDir)
    inputs.files("classesRelativePath")
    doLast {
        mkdir(classesDir)
        mkdir(destinationDir)
        // This works but is there a better way to deletage this task in Kotlin?
        ant.withGroovyBuilder {
            "taskdef"(
                    "name" to "wsgen",
                    "classname" to "com.sun.tools.ws.ant.WsGen",
                    "classpath" to taskCp
            )
            wsdlsToGenerate.forEach {
                val className = relativePath(it)
                        .replace("[\\\\/]".toRegex(), ".")
                        .replace("api.classes.", "")
                        .replace(".class", "")
                println("[wsgen] $className")
                "wsgen"(
                    "classpath" to cp,
                    "verbose" to false,
                    "genwsdl" to true,
                    "resourcedestdir" to destinationDir,
                    "sourcedestdir" to "api/java",
                    "keep" to true,
                    "sei" to className                      
                )
            }
        }
    }
}

В настоящее время обработка ~ 80 WSDLS занимает 7 минут.

...