Title: cxf-codegen-plugin in Gradle
Tags: maven;gradle;cxf;java-11
Question: I have below plugin in maven which is working fine. Now, I need to use the gradle version of project, so need to use the plugin in gradle. I tried below, but I am getting mentioned error. I am using Java 11. Any help/Suggestion is appreciable.
```<plugin&gt;
            <groupId&gt;org.apache.cxf</groupId&gt;
            <artifactId&gt;cxf-codegen-plugin</artifactId&gt;
            <version&gt;3.4.5</version&gt;
            <executions&gt;
                <execution&gt;
                    <id&gt;generate-sources</id&gt;
                    <phase&gt;generate-sources</phase&gt;
                    <configuration&gt;
                        <sourceRoot&gt;${basedir}/src/main/java</sourceRoot&gt;
                        <wsdlOptions&gt;
                            <wsdlOption&gt;
                                <wsdl&gt;${basedir}/src/main/resources/wsdl/CarServices.wsdl
                                </wsdl&gt;
                                <wsdlLocation&gt;classpath:wsdl/CarServices.wsdl
                                </wsdlLocation&gt;
                            </wsdlOption&gt;
                        </wsdlOptions&gt;
                    </configuration&gt;
                    <goals&gt;
                        <goal&gt;wsdl2java</goal&gt;
                    </goals&gt;
                </execution&gt;
            </executions&gt;
        </plugin&gt;
```
Below is the build.gradle file content
```    configurations {
        wsdl2java
    }

    dependencies {
        compile &quot;org.apache.cxf:cxf-spring-boot-starter-jaxws:3.4.5&quot;
    compile 'org.apache.cxf:cxf-rt-frontend-jaxws:3.4.5'
    compile 'org.apache.cxf:cxf-rt-transports-http:3.4.5'

    compile 'javax.xml.ws:jaxws-api:2.3.0'
    compile 'javax.jws:jsr181-api:1.0-MR1'
    compile 'javax.xml.bind:jaxb-api:2.3.0'

    wsdl2java 'javax.xml.bind:jaxb-api:2.3.0'
    wsdl2java 'com.sun.xml.bind:jaxb-ri:2.3.0'
    wsdl2java 'com.sun.xml.bind:jaxb-xjc:2.3.0'
    wsdl2java 'com.sun.xml.bind:jaxb-core:2.3.0'
    wsdl2java 'com.sun.xml.bind:jaxb-impl:2.3.0'

    wsdl2java 'javax.xml.ws:jaxws-api:2.3.0'
    wsdl2java 'javax.jws:jsr181-api:1.0-MR1'

    wsdl2java 'org.apache.cxf:cxf-tools-wsdlto-core:3.4.5'
    wsdl2java 'org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:3.4.5'
    wsdl2java 'org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:3.4.5'

    implementation 'javax.annotation:javax.annotation-api:1.3.2'
    annotationProcessor(&quot;javax.annotation:javax.annotation-api:1.3.2&quot;)
}

def wsdl2java = task generateJavaFromWsdl(type: JavaExec) {
    String wsdl = 'src/main/resources/wsdl/CarServices.wsdl'
    String genSrcDir = &quot;${projectDir}/build/generated-sources/CarServices&quot;

    inputs.file wsdl
    outputs.dir genSrcDir

    classpath configurations.wsdl2java
    main &quot;org.apache.cxf.tools.wsdlto.WSDLToJava&quot;

    args '-encoding', 'UTF-8', '-d', genSrcDir, wsdl

    OutputStream baos = new ByteArrayOutputStream()
    errorOutput = new OutputStream() {
        void write(int b) {System.err.write(b); baos.write(b) }
        void flush() { System.err.flush(); baos.flush() }
        void close() { System.err.close(); baos.close() }
    }

    doLast {
        def str = baos.toString()
        if (str.contains('Usage : wsdl2java') || str.contains('WSDLToJava Error')) {
            throw new TaskExecutionException(tasks[name],
                    new IOException('Apache CXF WSDLToJava has failed. Please see System.err output.'))
        }
    }
}
compileJava.dependsOn += wsdl2java
sourceSets.main.java.srcDirs = ['src/main/java', 'build/generated-sources/CarServices']
```
Getting below error while building and NO Java binding classes got created
```Caused by: java.lang.ClassNotFoundException: javax.annotation.Resource
```



Here is another answer: Answering my own question as it may help someone else. Below &quot;build.gradle&quot; config works with Java 11.. It creates required Java binding classes along with port class (Interface) also.. Reference links are attached.
https://ciscoo.github.io/cxf-codegen-gradle/docs/1.0.0-rc.3/user-guide/
```    buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
}

plugins {
    id 'org.springframework.boot' version '2.6.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id &quot;io.mateo.cxf-codegen&quot; version &quot;1.0.0-rc.3&quot;
}

apply plugin: 'groovy'
apply plugin: 'java'

group = 'com.example'
version = '0.0.1-SNAPSHOT'

sourceCompatibility = '11'
targetCompatibility = '11'

repositories {
    mavenCentral()
}


dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    
    implementation 'org.springframework.boot:spring-boot-starter-web-services'
    
    implementation 'org.codehaus.groovy:groovy-all:3.0.2'
    
    cxfCodegen &quot;jakarta.xml.ws:jakarta.xml.ws-api:2.3.3&quot; 
    cxfCodegen &quot;jakarta.annotation:jakarta.annotation-api:1.3.5&quot; 
    implementation 'javax.jws:javax.jws-api:1.1'
}

cxfCodegen {
    wsdl2java {
        example {
            wsdl = file(&quot;${projectDir}/src/main/resources/wsdl/BLZService.wsdl&quot;)
            outputDir = file(&quot;${buildDir}/generated-java&quot;) 
            markGenerated = true
        }
    }
}

compileJava.dependsOn wsdl2java


test {
    useJUnitPlatform()
}
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:12/20/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<maven><gradle><cxf><java-11>', 'Title': 'cxf-codegen-plugin in Gradle', 'ViewCount': 1415, 'id': 70423036, 'user_AboutMe': None, 'user_AccountId': 16684032.0, 'user_DisplayName': 'Balaji211', 'user_Reputation': 187.0, 'user_Views': 69.0, 'user_id': 12058407.0}}