boothen / gradle-wsimport

Yet Another WsImport Gradle Plugin.
https://plugins.gradle.org/plugin/uk.co.boothen.gradle.wsimport
Apache License 2.0
12 stars 11 forks source link

Versions newer than 0.17 use jakarta package for WebServiceFeature even when target is set to 2.2 (or 2.0) #27

Closed AlexanderSchuetz97 closed 11 months ago

AlexanderSchuetz97 commented 11 months ago

I had to downgrade the plugin to 0.17 prevent the generator from using the jakarta annotations for javax.xml.ws.WebServiceFeature includeDependencies = false was set, this did not help.

This strage thing was, the wrong annotations were only used in the Service classes that are generated when extension=true is used. After downgrading the plugin all was well

boothen commented 11 months ago

Hi @AlexanderSchuetz97,

Can you provide more specific details? Such as your build.gradle file or the generated class file. I've tried to reproduce your issue, but didn't succeed.

I used the following configuration and didn't see any issue with the service class imports.

dependencies {
    jaxWsTools "com.sun.xml.ws:jaxws-tools:2.3.2"

    implementation "javax.xml.bind:jaxb-api:2.3.1"
    implementation "javax.xml.ws:jaxws-api:2.3.1"
    implementation "javax.jws:javax.jws-api:1.1"
}

wsimport {
    extension = true
    includeDependencies = false
    target = 2.2
...
}

The imports were generated as follows

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;

Cheers, Matt.

AlexanderSchuetz97 commented 11 months ago

jaxWsTools "com.sun.xml.ws:jaxws-tools:2.3.2" I did not have this.

My build.gradle.kts looks similar to this: All you have to do to reproduce is change plugin version to newest and uncomment the includeDependencies = false line

plugins {
    java
    `java-library`
    `maven-publish`
    id("uk.co.boothen.gradle.wsimport") version "0.17" 
}

wsimport {
    wsdlSourceRoot = "src/main/resources/wsdlsrc"
    generatedSourceRoot = "../src/main/java"
    generatedClassesRoot = "build/noop"
    //includeDependencies = false

    target = "2.2"
    keep = true
    extension = true
    verbose = true
    quiet = false
    xnocompile = true
    xadditionalHeaders = false
    wsdl("ihe_framework/iti86.wsdl")
    wsdls[0].packageName = "ch.imagic.soap.generated.iti86"

    wsdl("ihe_framework/iti41.wsdl")
    wsdls[1].packageName = "ch.imagic.soap.generated.iti41"

    wsdl("rahulsom_ihe_iti/iti/wsdl/PIXManager.wsdl")
    wsdls[2].packageName = "ch.imagic.soap.generated.iti45"

    wsdl("ihe_framework/rad69.wsdl")
    wsdls[3].packageName = "ch.imagic.soap.generated.rad69"

    val wsImportTask = tasks.create("wsImport")

    for (i in 1 .. wsdls.size) {
        wsImportTask.dependsOn("wsImport$i")
    }
}

tasks.getByName("compileJava").dependsOn("wsImport")
tasks.getByName("sourcesJar").dependsOn("wsImport")

tasks.getByName("clean").doFirst {
    delete("${projectDir}/src/main/java/ch/imagic/soap/generated")
    println("Deleted Generated Soap Apis")
}

dependencies {
    api("javax.jws:javax.jws-api:1.1")
    api("javax.xml.ws:jaxws-api:2.3.1")
}
boothen commented 11 months ago

You'll need to add jaxWsTools "com.sun.xml.ws:jaxws-tools:2.3.2"

as that's the tool used to generate the code. 2.3.2 will use the older javax.* imports.

Add that and I'll be know how it goes.

Cheers, Matt.

AlexanderSchuetz97 commented 11 months ago

How would i do that? jaxWsTools("com.sun.xml.ws:jaxws-tools:2.3.2") does not kotlin compile grafik I am using gradle 8.4

AlexanderSchuetz97 commented 11 months ago

Never mind, ofc i have to update the plugin first...

Now it all works out, thank you very much