jaxb2 maven plugin, define multiple schema files in separate tags

Zygimantas Gatelis picture Zygimantas Gatelis · Apr 4, 2013 · Viewed 7.3k times · Source

I'm using maven jaxb2 plugin to generate Java classes from xsd files. Recently i faced problem, my schema files list geting really long, and I wrote all of them down in shemaFiles tag as comma separated values, and the line itself is very long and i'm afraid that in future it can affect code readability and be a bug reason. So is there any solution to write files in separate tags like:

<schemaFilesList>
  <schemaFile>SharedResources/xsd/Common.xsd</schemaFile>
  <schemaFile>SharedResources/xsd/Another.xsd</schemaFile>
          .... 
 </schemaFilesList>

Here is code I have for now:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>jaxb2-maven-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>xjc</goal>
      </goals>
      <configuration>
        <extension>true</extension>
        <schemaDirectory>target/xsd</schemaDirectory>
        <!-- I have really long list of files here, in different directories-->
        <schemaFiles>
           SharedResources/xsd/Common.xsd,SharedResources/xsd/Messaging/EmailService.xsd, .....
        </schemaFiles>
      </configuration>
    </execution>
  </executions>
</plugin>

Thanks in advance.

Answer

tdrury picture tdrury · Apr 4, 2013

We have a lot of schemas too. We simply leave out the <schemaFiles> element and let it read all schemas in the <schemaDirectory>.