Jump to: navigation, search

Difference between revisions of "SMILA/Development Guidelines/Setup for JAXB code generation"

Line 2: Line 2:
  
 
* Setup a build environment as described in [[SMILA/Development Guidelines/Howto build a SMILA-Distribution]].
 
* Setup a build environment as described in [[SMILA/Development Guidelines/Howto build a SMILA-Distribution]].
* Download JAXB 2.1.6 from [https://jaxb.dev.java.net/2.1.6/ https://jaxb.dev.java.net/2.1.6/], unpack it as described and copy <tt>jaxb-ri-20071219/lib/jaxb-xjc.jar</tt> to <tt>lib/xjc</tt> in the directory containing the additional libraries for building you created in the first step. Download <tt>InterfacesXJCPlugin.jar</tt> from [http://xml.w-wins.com/xjc-plugins/interfaces/ http://xml.w-wins.com/xjc-plugins/interfaces/] and add it to the lib/xjc directory, too. Your build lib directory should now look at least like this:
+
* Download the JAXB reference implementation 2.1.6 from [https://jaxb.dev.java.net/2.1.6/ https://jaxb.dev.java.net/2.1.6/], unpack it as described and copy <tt>jaxb-ri-20071219/lib/jaxb-xjc.jar</tt> to <tt>lib/xjc</tt> in the directory containing the additional libraries for building you created in the first step. Download <tt>InterfacesXJCPlugin.jar</tt> from [http://xml.w-wins.com/xjc-plugins/interfaces/ http://xml.w-wins.com/xjc-plugins/interfaces/] and add it to the lib/xjc directory, too. Your build lib directory should now look at least like this:
 
<source lang="text">
 
<source lang="text">
 
lib/
 
lib/

Revision as of 04:15, 22 April 2009

This page describes additional setup steps you need to do if you want to use JAXB to generate classes from XML schema descriptions for SMILA. This is also needed to be able to extend SMILA XML configuration file schemas, because we mostly use JAXB to parse them.

lib/
   ant-contrib/
      ant-contrib-1.0b1.jar
   xjc/
      jaxb-xjc.jar
      InterfacesXJCPlugin.jar
  • If you want to generate JAXB classes for a new crawler configuration:
    • If you do not yet have a binary distribution of SMILA: Download or build one.
    • Copy org.eclipse.smila.connectivity.framework.schema_0.5.0.jar from the plugins directory of the SMILA distribution to lib/xjc. This is necessary because crawler configurations extend a base schema and therefore need to access classes in this bundle.
  • Put your bundle next to all the SMILA source bundles.
  • Create a schemas directory in your bundle and put the XSD and JXB file there (use the same basename and xsd and jxb as suffixes).
  • Create a build.xml in the bundle directory with this content, replace $SCHEMA_NAME with the basename of the XSD/JXB files:
<project name="sub-build" default="compile-schema-and-decorate" basedir=".">
  <property name="schema.name" value="$SCHEMA_NAME" />
  <import file="../SMILA.builder/xjc/build.xml" />
</project>
  • You can optionally add a file copyright.txt to the bundle (next to build.xml) containing a copyright header for the generated files (use valid Java comment syntax).
  • Add a code/gen folder to your bundle and add it as a source folder.

To generate the classes, you can now use:

ant -Dlib.dir=<SMILA-Build-Lib-Dir>

If you have created the folder with the build libs in the same directory where the source bundles are located, you can just use:

ant

The JAXB classes should now be generated in the code/gen directory of your bundle.