module Buildr module OpenJPA VERSION = "0.9.7-incubating-SNAPSHOT" REQUIRES = [ "org.apache.openjpa:openjpa-all:jar:#{VERSION}", "commons-collections:commons-collections:jar:3.1", "commons-dbcp:commons-dbcp:jar:1.2.1", "commons-lang:commons-lang:jar:2.1", "commons-pool:commons-pool:jar:1.2", "javax.persistence:persistence-api:jar:1.0", "org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec:jar:1.0", "org.apache.geronimo.specs:geronimo-jta_1.0.1B_spec:jar:1.0", "net.sourceforge.serp:serp:jar:1.11.0" ] OPTIONS = [ :verbose, :noop, :cp, :classpath, :properties ] def self.enhance(options) options[:verbose] ||= Rake.application.options.trace || false fu_check_options options, *OPTIONS + [:output] runtool options.merge(:class=>"org.apache.openjpa.enhance.PCEnhancer", :name=>"Enhancer", :args=>{ "-p"=>options[:properties], "-d"=>options[:output] }, :classpath=>options[:classpath] + [options[:output]]) end def self.mapping_tool(options) options[:verbose] ||= Rake.application.options.trace || false fu_check_options options, *OPTIONS + [:action, :sql] runtool options.merge(:class=>"org.apache.openjpa.jdbc.meta.MappingTool", :name=>"Mapping Tool", :args=>{ "-p"=>options[:properties], "-sql"=>options[:sql], "-sa"=>options[:action] }) end protected def self.runtool(options) args = [options[:class]] + options[:args].select { |n, v| v }.map { |n, v| [ n, v ] }.flatten args << { :classpath=>requires + (options[:classpath] || []), :name=>"OpenJPA #{options[:name]}", :verbose=>options[:verbose] } java *args end def self.requires() @required ||= artifacts(REQUIRES).each { |artifact| artifact.invoke }.map(&:to_s) end end end