Skip to content

Instantly share code, notes, and snippets.

@galak-fyyar
Created October 19, 2011 09:25
Show Gist options
  • Save galak-fyyar/1297833 to your computer and use it in GitHub Desktop.
Save galak-fyyar/1297833 to your computer and use it in GitHub Desktop.
Generating XML Shema from POJO using Maven
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<sourceRoot>${project.build.directory}/generated-resources</sourceRoot>
<tasks>
<taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask" classpathref="maven.plugin.classpath"/>
<mkdir dir="${project.build.directory}/generated-resources"/>
<schemagen destdir="${project.build.directory}/generated-resources" classpathref="maven.plugin.classpath">
<schema namespace="urn:cws:security" file="security-profiles.xsd" />
<src path="${project.build.sourceDirectory}"/>
<src path="${basedir}/../some-relative-path/src/main/java/"/>
<include name="org/sokolenko/SomeClassA.java"/>
<include name="org/sokolenko/SomeClassB.java"/>
<include name="org/sokolenko/SomeClassC.java"/>
<include name="org/sokolenko/package-info.java"/>
<include name="org/sokolenko/model/**"/>
</schemagen>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.galak</groupId>
<artifactId>some-artifatc</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
</plugin>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment