0

IntelliJ IDEA 2022.1.3 (Community Edition

In my java project I use Ant to build project. To generate java files from wsdl file I use this Ant's target:

<!-- CXF -->
    <property name="cxf.home" location="c:/Programs/apache-cxf-3.1.7" />

    <path id="cxf.classpath">
        <fileset dir="${cxf.home}/lib">
            <include name="*.jar" />
        </fileset>
    </path>

    <target name="cxfWSDLToJava">
        <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
            <arg value="-client" />
            <arg value="-d" />
            <arg value="src" />
            <arg value="c:\temp\wsdl\Sign.wsdl.xml" />
            <classpath>
                <path refid="cxf.classpath" />
            </classpath>
        </java>
    </target>

It's work fine.

But I want to migrate to Gradle. And the question is:

How I can generate java files from wsdl file by Gradle?

Alexei
  • 14,350
  • 37
  • 121
  • 240
  • Does the [info here](https://stackoverflow.com/a/22461100/7644018) help? – Paul T. Jul 16 '22 at 16:27
  • @PaulT. No, I use IntelliJ IDEA 2022.1.3 (Community Edition – Alexei Jul 16 '22 at 16:30
  • 1
    Ok, then maybe [this link](https://www.jetbrains.com/help/idea/generate-java-code-from-wsdl-or-wadl-dialog.html#:~:text=Technically%2C%20IntelliJ%20IDEA%20generates%20Java,Java%20Code%20From%20WSDL%20dialog.&text=Specify%20the%20location%20of%20the%20target%20Web%20service%20WSDL%20descriptor.&text=Specify%20the%20credentials%20for%20accessing%20the%20WSDL%20URL%20address.) ? – Paul T. Jul 16 '22 at 16:44
  • IntelliJ Community Edition doesn't have enterprise features like that. – dan1st Jul 16 '22 at 18:13
  • @PaulT. Is it possible to generate java files by Gradle task? – Alexei Jul 16 '22 at 18:39
  • Any Ant task can be run from Gradle, even if there isn’t a “native” Gradle approach. There are multiple options for generating Java from WSDL in Gradle; searching the web will find them. – Dave Newton Jul 16 '22 at 18:41

1 Answers1

1

You can use CXF Codegen Gradle to do this since you are already using org.apache.cxf.tools.wsdlto.WSDLToJava. The plugin provides a DSL over the CLI options of the tool.

Minimum example:

tasks.register("sign", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
    toolOptions {
        wsdl.set(file("path/to/Sign.wsdl"))
    }
}

See the docs for full list of supported options.


Note: I am the author of the plugin.

Cisco
  • 20,972
  • 5
  • 38
  • 60