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

Java 9 Maven Plugin Support #4

Open
greenwoodma opened this issue May 22, 2018 · 8 comments
Open

Java 9 Maven Plugin Support #4

greenwoodma opened this issue May 22, 2018 · 8 comments
Assignees
Labels

Comments

@greenwoodma
Copy link
Member

To allow the model to correctly generate XML descriptors under Java 9 when the code is run from within a Maven plugin we can't rely on package-info so we need to internalise all the info by adding -npa to the call to XJC. See openminted/omtd-share-annotations#45 for full details.

@reckart
Copy link
Member

reckart commented May 22, 2018

@greenwoodma why can we not rely on package-info?

@reckart
Copy link
Member

reckart commented May 22, 2018

Never mind ;) Answer is here: openminted/omtd-share-annotations#45 (comment)

@greenwoodma
Copy link
Member Author

So I've now had the chance to try using 3.0.2-SNAPSHOT and I have good news and bad news.

The good news is that when running under Java 9 this version of the model produces a valid XML descriptor that validates against the XSD because XJC is run with the -npa option so as not to overwrite the custom details @courado added to package-info

The bad new is that under Java 9 the package-info classes are still completely ignored which means that the custom namespace prefix info in the hand crafted package-info.java files are ignored, so we end up with ns1: instead of ms: in the generated files.

While that's not ideal as you'll get different files when running under Java 8 and Java 9 both are valid given the XSD so that's probably good enough for me.

I guess that means we need to do a new release of the model which the maven plugin can then depend on.

@reckart
Copy link
Member

reckart commented May 23, 2018

Do you know if it is a known bug in Java 9 or JAXB that package-info is ignored? Do you have some issue tracker link?

@greenwoodma
Copy link
Member Author

Unfortunately I've been unable to find any mention of what the actual problem is no matter what I google for. If anyone comes across anything I'd be interested in what they find, but for now as I said it just completely ignores the info in package-info but I don't know if the problem is in java 9, maven, or JAXB 2.3.0 unfortunately

@reckart
Copy link
Member

reckart commented May 24, 2018

... overwrite the custom details @courado added to package-info

What custom details do you mean? The omtd-model-3.0.2.jar does not seem to include any package-info.classfiles?

@greenwoodma
Copy link
Member Author

What custom details do you mean? The omtd-model-3.0.2.jar does not seem to include any package-info.classfiles?

So in omtd-model:3.0.2 there is a eu.openminted.registry.domain.package-info class generated by XJC (I've double checked the jar on central and the class is definitely there). It basically specifies the default namespace for all elements where it is not set in the Java class files in the same package. This file is ignored when run as parts of a maven plugin under Java 9 which is why the validation then fails as the prefix is missing from the XML elements (as described in the omtd-share-annotations issue)

In 3.0.2-SNAPSHOT (i.e. the develop branch which should really by 3.0.3-SNAPSHOT or something) there is actually a package-info.java in the main source tree as @courado has added explicit prefix mappings for the namespaces. Because of this custom file XJC is run with the -npa option so as not to generate it's own package-info.java files which would override the custom settings. This means that with 3.0.2-SNAPSHOT the namespace information is correctly embedded in the generated Java source files and hence works when used in the maven plugin under Java 9. The custom namespace prefix mappings are however missing in that situation because the package-info class is still ignored.

@reckart
Copy link
Member

reckart commented May 24, 2018

Right - found the package-info.class doing a grep over the JAR. Thanks again.

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

No branches or pull requests

3 participants