title: How to recursively parse xsd files to generate a list of included schemas for incremental build in Maven?
body: <p>I have a Maven project that uses the <a href="http://mojo.codehaus.org/jaxb2-maven-plugin/xjc-mojo.html" rel="nofollow">jaxb2-maven-plugin</a> to compile some xsd files.  It uses the <code>staleFile</code>  to determine whether or not any of the referenced <code>schemaFiles</code> have been changed.  Unfortunately, the xsd files in question use <code>&lt;xs:include schemaLocation="../relative/path.xsd"/&gt;</code> tags to include other schema files that are not listed in the <code>schemaFile</code> argument so the <code>staleFile</code> calculation in the plugin doesn't accurately detect when things need to be actually recompiled.  This winds up breaking incremental builds as the included schemas evolve.</p>
  
  <p>Obviously, one solution would be to list all the recursively referenced files in the execution's <code>schemaFile</code>.  However, there are going to be cases where developers don't do this and break the build.  I'd like instead to automate the generation of this list in some way.</p>
  
  <p>One approach that comes to mind would be to somehow parse the top-level XSD files and then either sets a property or outputs a file that I can then pass into the <code>schemaFile</code> parameter or <code>schemaFiles</code> parameter.  The Groovy gmaven plugin seems like it might be a natural way to embed that functionality right into the POM.  But I'm not familiar enough with Groovy to get started.</p>
  
  <p>Can anyone provide some sample code?  Or offer an alternative implementation/solution?</p>
  
  <p>Thanks!</p>