Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent API options #14

Open
pewsplosions opened this issue Mar 20, 2021 · 0 comments
Open

Fluent API options #14

pewsplosions opened this issue Mar 20, 2021 · 0 comments

Comments

@pewsplosions
Copy link

Hi, I have inherited an old project and have been tasked with upgrading everything at once. It is kind of a nightmare and I don't know a whole lot about all this anyway. One of the upgrades is going from Ant to Gradle and from Java 8 to Java 15 and updating Jaxb to 3.0 as well.

Of all the gradle jaxb plugins I found, this one seemed the best so I went with it. Got everything generating pretty well but it is not quite the same as it used to be. So I was hoping maybe I could get some help on this.

The previous ant target to build looked like this:

    <target name="gen-jaxb" depends="init,clean-gen-jaxb" 
        description="Generates Java classes from the XSD definitions">
        <taskdef name="xjc" classname="com.sun.tools.xjc.XJC2Task">
            <classpath>
                <fileset id="xjc" dir="${deps.dir}/jaxb-xjc" includes="**/*.jar" />
            </classpath>
            <classpath path="${project.buildpath}" />
        </taskdef>
        <xjc destdir="${src}">
            <binding file="bindings.xml"/>
            <schema dir="schemas" includes="**/*.xsd" />
            <arg value="-verbose"/>
            <arg value="-npa"/>
            <arg value="-extension"/>
            <arg value="-Xinject-code"/>
            <arg value="-Xfluent-api"/>
            <arg value="-Xcommons-lang"/>
            <arg value="-Xannotate"/>
        </xjc>
    </target>

I have translated that to this:

plugins {
  id "com.github.bjornvester.xjc" version "1.5.0"
}
dependencies {
  xjc "org.glassfish.jaxb:jaxb-runtime:3.0.0"
  xjc "org.glassfish.jaxb:jaxb-xjc:3.0.0"
}
xjc {
  xjcVersion.set("3.0.0")
  xsdDir.set(file("schemas"))
  outputJavaDir.set(file("src/main/xjc"))
  options.add("-verbose")
  options.add("-npa")
  options.add("-extension")
  options.add("-Xinject-code")
  options.add("-Xfluent-api")
  options.add("-Xcommons-lang")
  options.add("-Xannotate")
}

The first error I've run into for the actual build is the lack of a fluent API. So I'm guessing that I am doing the args wrong in this gradle plugin. I read that options was for 3rd party plugins. So I wasn't sure this would just work anyway. But gave it a shot.

So I guess my question is. How would I translate the args from the ant target to this gradle plugin?

Is it even possible? Or are those only Jaxb 2 options? Or do I need an additional gradle plugin?

I've been working on this about 15 hours straight now so thought I'd stop trying things and ask. :D

Any help is greatly appreciated! :) Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant