Included JAXB episode pack not working

I have two circuits A, B. I am reusing some elements of A in B.

I do not use namespaces.

I use

<groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.9.0</version> 

I defined the inclusion of circuit A in circuit B as:

 <xs:include schemaLocation="classpath:my.schema.A.xsd"/> 

and the directory is

 REWRITE_SYSTEM "classpath:my.schema.A.xsd" "maven:my.schema:schema-a!/A.xsd" 

Jaxb configuration:

 <configuration> <generatePackage>my.schema.b</generatePackage> <schemaIncludes> <includes>B.xsd</includes> </schemaIncludes> <episodes> <episode> <groupId>my.schema</groupId> <artifactId>schema-a</artifactId> </episode> </episodes> <catalog>src/main/catalog/catalog.cat</catalog> </configuration> 

The problem is that whenever I specify an episode dependency, the circuit does not generate any classes, even if it contains some B elements that I want to generate for the classes.

 [INFO] Parsing input schema(s)... [INFO] Compiling input schema(s)... [INFO] Cleaning package directories. [INFO] Finished execution. 

When I delete an episode, it works well and generates classes for Scheme A, which I really want to avoid.

Do you have any suggestions?

The sample was published in the episodic assembly Jaxb

+6
source share
2 answers

Ok, I checked your example. The problem is that you are not using namespaces.

Check out the META-INF/sub-jaxb.episode :

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"> <jaxb:bindings scd="x-schema::"> <jaxb:schemaBindings map="false"> <jaxb:package name="schema.episode.a"/> </jaxb:schemaBindings> <jaxb:bindings scd="person"> <jaxb:class ref="schema.episode.a.Person"/> </jaxb:bindings> </jaxb:bindings> </jaxb:bindings> 

You see this <jaxb:bindings scd="x-schema::"> and then <jaxb:schemaBindings map="false"> . This basically means that the XJC "doesn't display anything in the empty namespace." Since your second schema ( b.xsd ) also does not use namespaces when you use the a.xsd episode file (link above), you also suppress code generation for b.xsd .

To summarize, when using episodes / separate schema compilation, you cannot put schemas with the same namespace in different episodes. This is just the problem with include .

This is not a maven-jaxb2-plugin error. I would not call it a bug in XJC either. This is exactly how episodes work by default.

See my pull request here , it demonstrates episodic compilation when namespaces are processed.

+5
source

The author of maven-jaxb2-plugin here.

I assume that your episode says something like "don't compile namespaces A and B". Check the binding file inside META-INF in the JAR.

This is a fairly advanced use, there are quite a few points where this may go wrong. You're using:

  • catalogs
  • Maven artifact-based schema resolution
  • episodes

Directories and episodes are XJC functions, Maven permission comes from maven-jaxb2-plugin . We should try to highlight what fails:

  • Try it simply with episodes - extract your circuits and compile "as is", without directories and recognizer.
  • Just directories - extract the scheme and rewrite it to local directories instead of maven:
  • Try maven:my.schema:schema-a!/A.xsd as a schema location without episodes and directories

Obviously, three more combinations to try.

If you provide a sample project, I will research (but not over the next 10 days). It would be best to record the problem. I will move the plugin to GitHub, so this will be a good place:

https://github.com/highsource/maven-jaxb2-plugin

0
source

Source: https://habr.com/ru/post/974986/


All Articles