stianh / gradle-jaxb-plugin

Gradle plugin for generating jaxb classes.
17 stars 11 forks source link

Do not force jaxb-xjc to be in compile configuration #10

Open mraccola opened 12 years ago

mraccola commented 12 years ago

The plugin currently requires the jaxb-xjc library to be added to the jaxb Configuration. The compile Configuration inherits from the jaxb Configuration which ultimately means that the jaxb-xjc library MUST be a part of the compile Configuration.

This is unwanted. The jaxb-xjc library is only needed during the build process to generate the Java classes it is not needed to actually compile the code.

One example of an unwanted side effect of this is that if you have a WAR file that depends on the project that has the jaxb plugin applied, the WAR file will end up with a jaxb-xjc.jar file in the WEB-INF/lib, unnecessarily bloating the WAR file. This of course can be worked around by excluding the jaxb-xjc from the War project's compile dependency but this should not be necessary.

Also, in regards to compiling the generated Java files I realize we still need to add the jaxb-api/jaxb-impl JARs to the compile Configuration. Please consider whether it is the job of the jaxb plugin to actual assist in seting up these JARs in the compile Configuration at all? Perhaps it is just expected that the jaxb-api/jaxb-impl will be added to the normal compile Confguration directly like this:

compile ("com.sun.xml.bind:jaxb-impl:2.1.3")

instead of

jaxb ("com.sun.xml.bind:jaxb-impl:2.1.3")

Not saying I have a strong opinion...just a question.

stigkj commented 12 years ago

First off, thank you very much for helping out! This is exactly why GitHub is so great.

Good catch with the compile inherits from jaxb configuration. I think I'm gonna split it into 2 configurations, 1 for the xjc compiler and 1 for the jaxb-impl/api and other dependencies the generated code needs for compilation. And compile will only inherit from the latter whereas the first is standalone.

Does this sound good?

mraccola commented 12 years ago

Yes, this sounds good.

Thanks for writing the plugin and being so fast at responding. I'm sorry I haven't been able to submit more patches myself...too busy with other stuff right now.