I'm new to Maven, and am trying to use it to generate the Java classes from my XSD.
My xsd file is in src/main/resources/xsd
In dependencies I have this, but I don't think I need it as I'm using Java 1.6
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.0</version>
</dependency>
In the build section I have
<build>
<pluginManagement>
..
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
..
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<includeSchemas>
<includeSchema>**/test.xsd</includeSchema>
</includeSchemas>
<generatePackage>com.myproject.adapter.generated</generatePackage>
<bindingDirectory>src/main/binding</bindingDirectory>
<removeOldOutput>true</removeOldOutput>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
But, when I run it, I get nothing. I've run mvn compile and generate-sources, with the -e and -X flags to have a look at the output, but it seems the target isn't getting invoked. Any ideas ?
first off you should always specify which version of a dependency or plugin you are using
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
then you have to supply the following entries inside an execution
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>test.xsd</include>
</schemaIncludes>
Here is a complete definition, I have included the jaxb2-basics plugin as you almost always want what it does.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>jaxb-test</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>test.xsd</include>
</schemaIncludes>
</configuration>
</execution>
</executions>
<configuration>
<extension>true</extension>
<args>
<arg>-XtoString</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-Xcopyable</arg>
<arg>-Xmergeable</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.0</version>
</plugin>
</plugins>
</configuration>
</plugin>