Module Buildr::Hibernate
In: addon/buildr/hibernate.rb  (CVS)

Provides Hibernate Doclet and schema export tasks. Require explicitly using require "buildr/hibernate".

Methods

Included Modules

Buildr::Ant

Constants

REQUIRES = Buildr.struct( :collections => "commons-collections:commons-collections:jar:3.1", :logging => "commons-logging:commons-logging:jar:1.0.3", :dom4j => "dom4j:dom4j:jar:1.6.1", :hibernate => "org.hibernate:hibernate:jar:3.1.2", :xdoclet => Buildr.group("xdoclet", "xdoclet-xdoclet-module", "xdoclet-hibernate-module", # :under=>"xdoclet", :version=>"1.2.3") + ["xdoclet:xjavadoc:jar:1.1-j5"] :under=>"xdoclet", :version=>"1.2.3") + ["xdoclet:xjavadoc:jar:1.1"]

Public Class methods

Uses XDoclet to generate HBM files form annotated source files. Options include:

  • :sources — Directory (or directories) containing source files.
  • :target — The target directory.
  • :excludetags — Tags to exclude (see HibernateDocletTask)

For example:

 doclet :sources=>compile.sources, :target=>compile.target, :excludedtags=>"@version,@author,@todo"

Runs the Hibernate SchemaExportTask with the specified properties. For example:

  Buildr::Hibernate.schemaexport(:properties=>properties.to_s, :quiet=>"yes", :text=>"yes", :delimiter=>";",
    :drop=>"no", :create=>"yes", :output=>target) do
    fileset :dir=>source.to_s, :includes=>"**/*.hbm.xml"
  end

Public Instance methods

Runs the hibernate doclet on the source files and creates HBM files in the target directory. By default runs on all source files, but you can limit it to a given package using the :package options. You can also pass other options to the doclet task.

For example:

  resources hibernate_doclet(:package=>"org.apache.ode.store.hib", :excludedtags=>"@version,@author,@todo")

Returns an new file task with an accessor (ant) to an AntProject that defines the schemaexport task. If called with a block, the task will yield to the block passing both itself and the Ant project.

See schemaexport.

For example:

  hibernate_schemaexport "derby.sql" do |task, ant|
    ant.schemaexport :properties=>"derby.properties", :output=>task.name,
      :delimiter=>";", :drop=>"no", :create=>"yes" do
      fileset(:dir=>compile.sources.first) { include :name=>"**/*.hbm.xml" } }
    end
  end

Protected Instance methods

This will download all the required artifacts before returning a classpath, and we want to do this only once.

[Validate]