Maven - Have an XSD as a dependency
maven-2, xsd
Solution
I don't know the attach-artifact goal but I did something like you asked for. I had wsdl and xsd files to write Webservice artifacts and its client artifacts with axis2.
- I put my wsdl and xsd in an own project named 'wsdl' to src/main/resources/META-INF and nothing else.
- I made a own project named 'soap' for the generated Java-SOAP-Code. In this project I added the the wsdl project as dependency and unpacked the wsdl and xsd files via maven-dependency-plugin to the target folder in the initialize-phase. So I can use it to generate the SOAP-Code.
- The soap project I used as dependency for the Webservice project and for the client project.
I put all these projects to a multi module project so that I can build all together. I think the important part for you is the configuration of dependency-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-wsdl-dependency</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${groupId}</groupId>
<artifactId>wsdl</artifactId>
<outputDirectory>target/wsdl</outputDirectory>
<includes>META-INF/*.wsdl,META-INF/*.xsd</includes>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</plugin>
Hope that helps.
Greetings Michael
Problem
We have one project that defines the message formats it produces with XSD files. What is the easiest way to make these XSD files as dependencies of another project? I was looking at using the maven-build-helper attach-artifact goal to attach my XSD files. Is there a better mechanism?