krasa / krasa-jaxb-tools

XJC / JAXB plugin for generation of Bean Validation Annotations (JSR-303) and replacing primitive types
Apache License 2.0
60 stars 49 forks source link

Support for org.codehaus.mojo JAXB-2 Maven Plugin (XML to Java) #36

Open tibortru opened 9 years ago

tibortru commented 9 years ago

http://mojo.codehaus.org/jaxb2-maven-plugin/

Here is their basic Java class generation from xml files http://mojo.codehaus.org/jaxb2-maven-plugin/example_xjc_basic.html

Is it possible, is it planned at all? Thx :+1:

krasa commented 9 years ago

Contributions are welcomed, it would be nice to add an example to https://github.com/krasa/krasa-jaxb-tools-example

userquin commented 8 years ago

It is possible, you only need to add this plugin as a dependency for jaxb2-maven-plugin and add -XJsr303Annotations to arguments.

For example, use -Xinheritance (I always use external customization files, so XSD has no xsd:appinfo) with this plugin (arguments must be in one line, you cannot enter LF):

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <dependencies> <dependency> <groupId>org.jvnet.jaxb2_commons</groupId> <artifactId>jaxb2-basics</artifactId> <version>0.6.4</version> <exclusions> <exclusion> <groupId>com.sun.xml</groupId> <artifactId>jaxb-xjc</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.github.krasa</groupId> <artifactId>krasa-jaxb-tools</artifactId> <version>1.3<version> </dependency> </dependencies> <configuration> <outputDirectory>src/main/java</outputDirectory> <schemaDirectory>src/main/resources/META-INF</schemaDirectory> <schemaFiles>XXXXX-v${pom.version}.xsd</schemaFiles> <bindingDirectory>src/main/xjb</bindingDirectory> <bindingFiles>XXXXXX-v${pom.version}.xjb</bindingFiles> <target>2.0</target> <clearOutputDir>false</clearOutputDir> <verbose>true</verbose> <failOnNoSchemas>false</failOnNoSchemas> <extension>true</extension> <enableIntrospection>true</enableIntrospection> <arguments>-Xinheritance -XJsr303Annotations</arguments> </configuration> <executions> <execution> <id>xjc</id> <phase>generate-sources</phase> <goals> <goal>xjc</goal> </goals> </execution> </executions> </plugin>