At my work used jaxws-maven-plugin for code generation. I have two projects are "common" and'' client ". Structure roughly as follows:
app/
common/
resource/
some.xsd
client/
resource/
some.wsdl
How can I generate classes from wsdl in the project "client", using the xsd from the project "common"?
pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<verbose>true</verbose>
<bindingFiles>
<bindingFile>${project.parent.basedir}/common/resource/some.xsd</bindingFile>
</bindingFiles>
<wsdlFiles>
<wsdlFile>/resource/some.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
First of all you should stick to the maven conventions, use
src/main/resources/directories for resources.After doing that then you can use the
maven-dependency-plugin:unpack-dependenciesto unpack thecommonjar file to access thesome.xsd:The
jaxws-maven-pluginis bound to thegenerate-sourcesphase so adding themaven-dependency-pluginbefore thejaxws-maven-pluginand to the same phase makes sure that it unpacks everything before applying thewsimportgoal.Make sure that
<bindingDirectory/>and<wsdlDirectory/>are correct.This is how you should do it if you have the
*.xsdfiles in another project. Never access other projects with relative paths. Each project should only access other resources using the dependency mechanism.