The solution I'm trying out uses episodes. In the POM file for the common schema, I have something like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/bindings</bindingDirectory>
<!-- The schema directory or xsd files. -->
<schemaDirectory>${basedir}/src/schema</schemaDirectory>
<!-- The working directory to create the generated java source files. -->
<outputDirectory>${build.directory}/generated-sources/jaxb</outputDirectory>
<arguments>-episode "${build.directory}/generated-sources/myCommonSchema.episode"</arguments>
</configuration>
</execution>
</executions>
</plugin>
The key here is <arguments>-episode "${build.directory}/generated-sources/myCommonSchema.episode"</arguments>
- this generates an episode file (named "myCommonSchema.episode" in the specified directory). The next step is to copy the episode file to the web service that depends on the common schema, and reference it as a binding file like this:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>MyService</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/</bindingDirectory>
<bindingFiles>
<bindingFile>myCommonSchema.episode</bindingFile>
</bindingFiles>
<wsdlDirectory>${basedir}/src/wsdl/MyWebService</wsdlDirectory>
<wsdlFiles>
<wsdlFile>MyWebService.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>META-INF/wsdl/MyWebService/MyWebService.wsdl</wsdlLocation>
<sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
<verbose>true</verbose>
<xdebug>true</xdebug>
<extension>true</extension>
<xjcArgs>
<xjcArg>-Xannotate</xjcArg>
</xjcArgs>
</configuration>
</execution>
I'm still testing with this, but it seems to work. The only awkward part is moving the episode file to the other clients, but there's probably a way to automate that.