Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

(Steps to install needed libraries)
(Steps to install needed libraries)
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=== Introduction ===
 
=== Introduction ===
  
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.
+
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.
 
+
  
 
=== Steps to install needed libraries ===
 
=== Steps to install needed libraries ===
Line 8: Line 7:
 
# Setup a build library as described in [[SMILA/Development Guidelines/Howto build a SMILA-Distribution]]. In this document we will use {{path|lib/}} as the root of it.
 
# Setup a build library as described in [[SMILA/Development Guidelines/Howto build a SMILA-Distribution]]. In this document we will use {{path|lib/}} as the root of it.
 
# The required JAXB compiler libraries are contained in our [http://ubuntuone.com/312LdFKCXLYfapEpxLMR9v package of the SMILA build libraries]. If you want to collect them on your own, use these instructions:
 
# The required JAXB compiler libraries are contained in our [http://ubuntuone.com/312LdFKCXLYfapEpxLMR9v package of the SMILA build libraries]. If you want to collect them on your own, use these instructions:
## Download the JAXB reference implementation 2.1.6 or above from [http://jaxb.java.net/]
+
## Download the JAXB reference implementation 2.1.6 or above from [http://jaxb.java.net/ http://jaxb.java.net/]
 
## unpack it with (see [https://jaxb.dev.java.net/2.1.6/  here]) <source lang="text">java -jar <JAXB-version>.jar </source>   
 
## unpack it with (see [https://jaxb.dev.java.net/2.1.6/  here]) <source lang="text">java -jar <JAXB-version>.jar </source>   
 
## copy the following into your <tt>lib/xjc</tt>  
 
## copy the following into your <tt>lib/xjc</tt>  
Line 34: Line 33:
  
 
The JAXB classes should now be generated in the <tt>code/gen</tt> directory of your bundle.
 
The JAXB classes should now be generated in the <tt>code/gen</tt> 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: [http://www.eclipse.org/smila/downloads.php Download] or build one.
 
# Copy <tt>org.eclipse.smila.connectivity.framework.schema_$VERSION.jar</tt> from the plugins directory of the SMILA distribution to <tt>lib/xjc</tt>. 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 <tt>SMILA.builder</tt> source bundle.
 
# Add a <tt>code/gen</tt> folder to your bundle and add it as a source folder.
 
# Create a <tt>schemas</tt> directory in your bundle and put the XSD and JXB file there (use the same basename and <tt>xsd</tt> and <tt>jxb</tt> as suffixes).
 
# Create a <tt>build.xml</tt> in the bundle directory with this content, replace $SCHEMA_NAME with the basename of the XSD/JXB files:
 
 
<source lang="xml">
 
<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>
 
</source>
 
 
You can optionally add a file <tt>copyright.txt</tt> to the bundle (next to build.xml) containing a copyright header for the generated files (use valid Java comment syntax).
 
  
  
 
[[Category:SMILA]]
 
[[Category:SMILA]]

Revision as of 05:46, 9 April 2013

Introduction

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.

Steps to install needed libraries

  1. 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.
  2. The required JAXB compiler libraries are contained in our package of the SMILA build libraries. If you want to collect them on your own, use these instructions:
    1. Download the JAXB reference implementation 2.1.6 or above from http://jaxb.java.net/
    2. unpack it with (see here)
      java -jar <JAXB-version>.jar
    3. copy the following into your lib/xjc
      • all jars in the jaxb-ri-<version>/lib/
      • InterfacesXJCPlugin.jar, you can download it here

Your build lib directory should now look at least like this:

lib/
   ant-contrib/
      ant-contrib-1.0b3.jar
   xjc/
      jaxb-api.jar
      jaxb-impl.jar
      jaxb-xjc.jar
      InterfacesXJCPlugin.jar

Generate Sources from Command line

  1. 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).
  2. To generate the classes, you can now use:
    ant -Dlib.dir=<SMILA-Build-Lib-Dir>

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

Copyright © Eclipse Foundation, Inc. All Rights Reserved.