JAXB XJC builder extension

This extension provides the ability to invoke jaxb xjc binding compiler xjc. A simple example of it’s use follows;

require 'buildr_jaxb_xjc'

define "foo" do
  project.version = "1.0.0"
  compile.from compile_jaxb(_('src/schemas/wildfire-1.3.xsd'),
                            "-quiet",
                            :package => "org.foo.api")
  package :jar
end

The method compile_jaxb accepts either an array of files or a single file as the first parameter. It then accepts 0 or more arguments that are passed to the underlying XJC compiler. The arguments are documented at [1] on the jaxb site. If the last argument is an options hash then the extension handles these specially. The supported options include:

* <tt>:directory</tt>: The directory to which source is generated. Defaults
  to <tt>_(:target, :generated, :jaxb)</tt>
* <tt>:keep_content</tt>: By default the generated directory will be deleted.
  If <tt>true</tt> is specified for this parameter the directory will not be
  deleted.
* <tt>:package</tt>: The package in which the source is generated.
1

jaxb.dev.java.net/nonav/2.2.1/docs/xjc.html

Installation

The extension is packaged as a gem named “buildr-jaxb-xjc”, consult the ruby gems installation steps but typically it is either

sudo gem install buildr-jaxb-xjc

for MRI ruby or

jgem install buildr-jaxb-xjc

for jruby.

The user then needs to add the following require into the build file:

require 'buildr_jaxb_xjc'