rackerlabs / gradle-jaxb-plugin

Gradle plugin to ease projects that use xsds and the ant jaxb task
GNU General Public License v2.0
34 stars 23 forks source link

import tags without schemaLocation attribute result in FileNotFoundException #45

Open andygoossens opened 5 years ago

andygoossens commented 5 years ago

The plugin is unable to cope with import tags without a schemaLocation attribute. e.g.

<import namespace="urn:ietf:params:xml:ns:eppcom-1.0"/>

If it encounters such tag, then the build will fail with a rather undescriptive error message:

Execution failed for task ':xsd-dependency-tree'.
> java.io.FileNotFoundException: /path/to/repo/gradle-jaxb-plugin-import-issue/src/main/resources/xsd (Is a directory)

I have created a simple testcase repository to reproduce this issue. While I can work around this issue by mentioning a schemaLocation attribute, I would rather avoid that. (The XSD files were copied from RFC 5730 and diverging from those would be undesirable.)

If I would be calling the Ant task XJC2Task directly, then I would have been able to provide a catalog file which it would use to understand how the namespaces and files fit together. Unfortunately, gradle-jaxb-plugin does not seem to support that. :-(

wdschei commented 5 years ago

@andygoossens Is there a reason you can't pass it as an XJC argument (e.g. -catalog <file>?

Similar to this example:

https://github.com/rackerlabs/gradle-jaxb-plugin/blob/master/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle#L15

andygoossens commented 5 years ago

I know I can pass it as a XJC argument, but the Gradle build will fail before reaching the "xjc" task. Task "xjc" depends on "xsd-dependency-tree" and it is the latter that fails.

I have tried excluding "xsd-dependency-tree", but that won't work either:

./gradlew clean xjc -x xsd-dependency-tree
> Task :xjc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':xjc'.
> Cannot get property 'managedNodes' on null object
drapej commented 5 years ago

@andygoossens : i have the same problem, did you find a solution ? Thank you

andygoossens commented 5 years ago

@drapej: I am not using this plugin anymore for my module that has this error. I went back to using Ant task XJC2Task.

drapej commented 5 years ago

@andygoossens : ok thank you. Is it possible to share your build.gradle with this ant task ?

andygoossens commented 5 years ago

@drapej: I cannot share the actual code as it can be considered to be proprietary, but it looks like this: https://stackoverflow.com/a/41880497