SMILA/Development Guidelines/Setup for JAXB code generation
< SMILA | Development Guidelines
Revision as of 08:25, 24 January 2012 by Juergen.schumacher.attensity.com (Talk | contribs) (→Generating JAXB classes for a new crawler or agent configuration)
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.
Steps to install needed libraries
- Setup a build library as described in SMILA/Development Guidelines/Howto build a SMILA-Distribution. In this document we will use lib/ as the root of it.
- Download the JAXB reference implementation 2.1.6 or above from here
- unpack it with (see here)
java -jar <JAXB-version>.jar
- copy the following into your lib/xjc
- all jars in the jaxb-ri-<version>/lib/
- InterfacesXJCPlugin.jar that you can get here
Your build lib directory should now look at least like this:
lib/ ant-contrib/ ant-contrib-1.0b1.jar xjc/ jaxb-xjc.jar InterfacesXJCPlugin.jar activation.jar jaxb-api.jar jaxb-impl.jar jsr173_1.0_api.jar
Generate Sources from Command line
- Put SMILA.builder into the same folder as the bundle for which you are generating the folder (for all SMILA bundles this is the case after a checkout).
- To generate the classes, you can now use:
The JAXB classes should now be generated in the code/gen directory of your bundle.
Generating JAXB classes for a new crawler or agent configuration
- If you do not yet have a binary distribution of SMILA: Download or build one.
- Copy org.eclipse.smila.connectivity.framework.schema_1.0.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 the SMILA.builder source bundle.
- Add a code/gen folder to your bundle and add it as a source folder.
- 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).