kuzznya

build.gradle with WSDL

Feb 10th, 2021
2,268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 3.15 KB | None | 0 0
  1. plugins {
  2.     id 'org.springframework.boot' version '2.3.2.RELEASE'
  3.     id 'io.spring.dependency-management' version '1.0.9.RELEASE'
  4.     id 'java'
  5. }
  6.  
  7. group = projectGroup
  8. version = projectVersion
  9. sourceCompatibility = '11'
  10.  
  11. configurations {
  12.     compileOnly {
  13.         extendsFrom annotationProcessor
  14.     }
  15.     jaxb
  16. }
  17.  
  18. repositories {
  19.     mavenCentral()
  20. }
  21.  
  22. ext {
  23.     wsdlSchemaUrl = "${System.getenv('SAP_URI') ?: 'http://support.alpeconsulting.com:8201/sap/bc/srt/rfc/sap/ztablereadws'}?wsdl"
  24.     wsdlPath = "${buildDir}/ztablereadws.wsdl"
  25.     wsdlUser = System.getenv('SAP_USERNAME') ?: sapUser
  26.     wsdlPassword = System.getenv('SAP_PASSWORD') ?: sapPassword
  27.     springCloudVersion = "Hoxton.SR7"
  28. }
  29.  
  30. task downloadWsdl {
  31.     file(buildDir).mkdir()
  32.     try {
  33.         ant.get(src: wsdlSchemaUrl, dest: wsdlPath, username: wsdlUser, password: wsdlPassword)
  34.     } catch (Exception ex) {
  35.         println 'Warning: cannot download new WSDL'
  36.         ex.printStackTrace()
  37.         if (!file(wsdlPath).exists()) {
  38.             println 'Fatal: no old WSDL found'
  39.             throw new RuntimeException("No WSDL found to generate code")
  40.         }
  41.     }
  42. }
  43.  
  44. task genJaxb {
  45.     dependsOn(downloadWsdl)
  46.  
  47.     ext {
  48.         sourcesDir = "${buildDir}/generated-sources/jaxb"
  49.         schema = wsdlPath
  50.     }
  51.  
  52.     doLast {
  53.         project.ant {
  54.             taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
  55.                     classpath: configurations.jaxb.asPath
  56.             mkdir(dir: sourcesDir)
  57.  
  58.             xjc(destdir: sourcesDir, schema: schema,
  59.                     package: "com.github.kuzznya.sap.wsdl") {
  60.                 arg(value: "-wsdl")
  61.                 produces(dir: sourcesDir, includes: "**/*.java")
  62.             }
  63.         }
  64.     }
  65. }
  66.  
  67. compileJava {
  68.     dependsOn(genJaxb)
  69.     sourceSets.main.java.srcDirs += 'build/generated-sources/jaxb'
  70. }
  71.  
  72. dependencyManagement {
  73.     imports {
  74.         mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  75.     }
  76. }
  77.  
  78. dependencies {
  79.     implementation project(":sap-drivers:sap-driver-api")
  80.     implementation project(":common")
  81.     implementation 'org.springframework.boot:spring-boot-starter-web'
  82.     implementation 'org.springframework.boot:spring-boot-starter-security'
  83.     implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
  84.     implementation 'org.springframework.boot:spring-boot-starter-actuator'
  85.     compileOnly 'org.projectlombok:lombok'
  86.     developmentOnly 'org.springframework.boot:spring-boot-devtools'
  87.     annotationProcessor 'org.projectlombok:lombok'
  88.     annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
  89.     testImplementation('org.springframework.boot:spring-boot-starter-test') {
  90.         exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  91.     }
  92.  
  93.     // Consuming SOAP:
  94.     implementation ('org.springframework.boot:spring-boot-starter-web-services')
  95.     implementation 'org.springframework.ws:spring-ws-core'
  96. // For Java 11:
  97.     implementation 'org.glassfish.jaxb:jaxb-runtime'
  98.  
  99.     jaxb "com.sun.xml.bind:jaxb-xjc:2.3.3"
  100. }
  101.  
  102. test {
  103.     useJUnitPlatform()
  104. }
Advertisement
Add Comment
Please, Sign In to add comment