I will explain what i want to accomplish since i'm not sure it's possible without some workaround. It needs to be noted that i MUST use java 11 but i can choose maven version and the JAXB plugin.
The layout
My xsd are organized in subfolders. Suppose this is the structure of the project:
xsdfolder
|-dir1
| `- file1.xsd
|-dir2
| `- file2.xsd
`- commontypes.xsd
Suppose file1 and file2 reference some type defined in common-types.
The objectives
What I want to obtain is a set of java classes such that:
the packages reflect the project structure i.e.
- all objects defined in file1 will be under com.example.xsdfolder.dir1
- all objects defined in file2 will be under com.example.xsdfolder.dir2
- all objects defined in commonTypes will be under com.example.xsdfolder
the types defined in commontypes are converted into classes just ONCE and they do not appear in dir1 or dir2. The classes in dir1/dir2 that use these types just import them from the com.example.xsdfolder package
I tried using jaxb2-maven-plugin and I managed to reach objective (1) by separating the executions: each execution gets its own package.
What i'm stuck at is objective (2). I think that the solution is a combination of bindings and episodes but i cannot find a maven configuration that lets me use them as i would like.
So my questions are:
- can this be done?
- can this be done with java 11 + maven through an already available plugin?
If necessary I will provide some of the configurations I tried.
Thank you!