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-dependencies
to unpack thecommon
jar file to access thesome.xsd
:The
jaxws-maven-plugin
is bound to thegenerate-sources
phase so adding themaven-dependency-plugin
before thejaxws-maven-plugin
and to the same phase makes sure that it unpacks everything before applying thewsimport
goal.Make sure that
<bindingDirectory/>
and<wsdlDirectory/>
are correct.This is how you should do it if you have the
*.xsd
files in another project. Never access other projects with relative paths. Each project should only access other resources using the dependency mechanism.