Closed buko closed 6 months ago
Hi, I think your suggestion is a very useful extension. Interestingly, however, the code you mention has worked with the highsource plugin in the past, as this is also the primary XJC maven plugin that jaxb-rich-contract-plugin has been tested with. Is it possible for you to send the XSDs and possibly XJB binding files as well as the maven pom you are trying to compile?
An example of a similar project is here: https://github.com/bubblegumproject/scrum4j-model
It's a multi-module, modular compilation schema project.
One thing I've been doing is to use the generatePackage
instruction: https://github.com/bubblegumproject/scrum4j-model/blob/master/scrum4j-model-project-binding/pom.xml#L57
This is as opposed to using the jaxb:package instruction which I couldn't get to work in a modular schema project.
In a modular schema project, you will have to put the binding customizations in a seperate binding.xjc file. It won't work with inline binding customizations. This has nothing to do with the jaxb2-rich-contract=plugin, but is an issue with modular projects ("episode" mechanism).
Compatibility fixed in 4.0.0
Hey, are you familiar with https://github.com/highsource/maven-jaxb2-plugin ? It's one of the few jaxb2 maven plugins still under active development.
I've been trying to use the jaxb2-rich-contract-plugin with the maven-jaxb2-plugin and running into strange errors around packages. These errors are all of the form:
org.xml.sax.SAXParseException; systemId: http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd; lineNumber: 369; columnNumber: 32; No package found for namespace http://www.w3.org/1999/xhtml at com.kscs.util.plugins.xjc.GroupInterfaceGenerator.createInterfaceDeclaration(GroupInterfaceGenerator.java:460) at com.kscs.util.plugins.xjc.GroupInterfaceGenerator.generateGroupInterfaces(GroupInterfaceGenerator.java:317) at com.kscs.util.plugins.xjc.GroupInterfaceGenerator.generateGroupInterfaceModel(GroupInterfaceGenerator.java:353) at com.kscs.util.plugins.xjc.GroupInterfacePlugin.generate(GroupInterfacePlugin.java:146) at com.kscs.util.plugins.xjc.GroupInterfacePlugin.run(GroupInterfacePlugin.java:131) at com.sun.tools.xjc.model.Model.generateCode(Model.java:292)
The problem seems to be in how the plugin is trying to discover the packages associated with a namespace for which code might be generated.
The code seems to fail in
GroupInterfaceGenerator.java
:private PackageOutline findPackageForNamespace(final String namespaceUri) { for (final PackageOutline packageOutline : this.pluginContext.outline.getAllPackageContexts()) { if (namespaceUri.equals(packageOutline.getMostUsedNamespaceURI())) { return packageOutline; } } return null; }
One possibility to fix it would be to allow, via configuration, the user to specifically indicate the package name to be used for the generated group interfaces. This might be a useful feature since I often prefer to put immutable interfaces in a package that is different from the mutable objects that implement those interfaces and then logically clients are exposed only to that package containing the immutable types.Perhaps something like:
-interfacePackages=${namespace}|${packageName}|${namespace2}|${packageName2}
as an option to be passed to the plugin?