带有wsdl2java的Gradle Kotlin DSL

问题描述 投票:1回答:1

从Groovy迁移到Kotlin,偶然发现了wsdl2java生成中的一个简单问题。

问题很简单,有人有很好的例子吗? Google并不是很有帮助,在Kotlin DSL方面也不是很好,但在语法上也不错。

也使用OpenJDK11。


plugins {
  id("no.nils.wsdl2java") version "0.10"
}


wsdl2java {
  enabled = true
  wsdlsToGenerate = [
    [
      "-xjc",
      "-p", "bla.bla.generated",
      "-wsdlLocation", "classpath:wsdl/v1.wsdl",
      "-autoNameResolution", "$projectDir/src/main/resources/wsdl/v1.wsdl"
    ],
    [
      "-xjc",
      "-p", "bla.bla.generated",
      "-wsdlLocation", "classpath:wsdl/v2.wsdl",
      "-autoNameResolution", "$projectDir/src/main/resources/wsdl/v2.wsdl"
    ]]
  generatedWsdlDir = file("$projectDir/src/main/java")
  wsdlDir = file("$projectDir/src/main/resources/wsdl")
}

dependencies {

  implementation(project(":common"))
  implementation(project(":etcd"))

  implementation("org.springframework.boot:spring-boot-starter-actuator")
  implementation("org.springframework.boot:spring-boot-starter-data-jpa")
  implementation("org.springframework.boot:spring-boot-starter-hateoas")
  implementation("org.springframework.boot:spring-boot-starter-quartz")
  implementation("org.springframework.boot:spring-boot-starter-security")
  implementation("org.springframework.boot:spring-boot-starter-validation")
  implementation("org.springframework.boot:spring-boot-starter-web")
  implementation("org.springframework.boot:spring-boot-starter-web-services")

  api("no.nils:wsdl2java")

  compileOnly("org.projectlombok:lombok")
  testImplementation("org.springframework.boot:spring-boot-starter-test")
  testImplementation("org.springframework.security:spring-security-test")
}

tasks.jar {
  archiveFileName.set("ext.jar")
}



gradle wsdl2java gradle-kotlin-dsl
1个回答
1
投票

我让wsdl2java通过以下试验和错误进行工作:

plugins {
    id("no.nils.wsdl2java") version "0.10"
}

wsdl2javaExt {
    cxfVersion = "3.3.0"
    deleteGeneratedSourcesOnClean = true
}

tasks.withType<no.nils.wsdl2java.Wsdl2JavaTask> {
    // The use of ArrayList(listOf) is necessary as the Wsdl2JavaTask seems to make inline changes to its arguments
    wsdlsToGenerate = listOf(
            ArrayList(listOf("-p", "dk.grydholt.integration.sacho",
                    "-autoNameResolution", "-xjc-npa",
                    "-wsdlLocation", "classpath:wsdl/sacho/EduModelService.wsdl",
                    "$projectDir/src/main/resources/wsdl/sacho/EduModelService.wsdl")))

    generatedWsdlDir = file("$projectDir/src/generated/java")
    wsdlDir = file("$projectDir/src/main/resources/wsdl/sacho")
}

sourceSets {
    create("generated") {
        java.srcDirs(listOf("src/generated/java"))
    }
}

注意使用ArrayList。我花了一些时间进行调试,因为如果执行listOf(listOf(“ ...”)),会出现奇怪的类型错误。

© www.soinside.com 2019 - 2024. All rights reserved.