Below is an example of how I've used Sun's XJC Ant task from Maven. The
<sourceRoot> tag is how I added the generated .java files to the sources
that are compiled. I also moved the generated non-java files to the
resources directory so that they would get included with the artifact
(JAR, WAR, etc.). All the dependencies were third party JARs that I had
to manually install in my repository.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"/>
<mkdir
dir="${project.build.directory}/generated-sources/jaxb/src/main/java"/>
<xjc
target="${project.build.directory}/generated-sources/jaxb/src/main/java"
schema="${basedir}/src/main/xsd/myschema.xsd"
package="com.mypackage">
<produces
dir="${project.build.directory}/generated-sources/jaxb/src/main/java/com/mypackage"
includes="**/*" />
</xjc>
<mkdir
dir="${project.build.directory}/generated-sources/jaxb/src/main/resources"/>
<move
todir="${project.build.directory}/generated-sources/jaxb/src/main/resources"
preservelastmodified="true"
includeEmptyDirs="false">
<fileset
dir="${project.build.directory}/generated-sources/jaxb/src/main/java"
excludes="**/*.java" />
</move>
</tasks>
<sourceRoot>${project.build.directory}/generated-sources/jaxb/src/main/java</sourceRoot>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.tools.xjc</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-libs</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.sun.xml</groupId>
<artifactId>xsdlib</artifactId>
<version>20050614</version>
</dependency>
<dependency>
<groupId>org.relaxng.datatype</groupId>
<artifactId>relaxngDatatype</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
Good luck,
Richard Allen
Jens Zastrow wrote:
Hi,
i need to use the sun-jaxb-compiler (xjc) which only seems to work
correctly with the antrun plugin.
The problem now is to put the generated .java files in a directory which
is a pom-source-folder or
one which is later added to the pom-source-folders.
Since i dont know a way to do this fromt he ant snipshet, my current -
bad - solution is to generate
them into ${basedir}/src/main/java.
Any ideas?
Thanks
jens
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<tasks>
<taskdef name="xjc"
classname="com.sun.tools.xjc.XJCTask"/>
<xjc
schema="src/main/xsd/de/dailab/util/jaxb/agentrole/AgentRole.xsd"
package="de.dailab.util.jaxb.agentrole"
target="${basedir}/src/main/java"
extension="false"/>
<copy
todir="${project.build.directory}/classes">
<fileset
dir="${basedir}/src/main/java" excludes="**/*.java"/>
</copy>
</tasks>
</configuration>
</executions>
</plugin>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]