lib/java/openjpa.rb in buildr-0.18.0 vs lib/java/openjpa.rb in buildr-0.19.0
- old
+ new
@@ -1,51 +1,63 @@
+require "java/java"
+
module Buildr
+ module Java
+ module OpenJPA
- module OpenJPA
+ VERSION = "0.9.7-incubating-SNAPSHOT"
- 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" ]
- 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, :classpath, :properties ]
- OPTIONS = [ :verbose, :noop, :cp, :classpath, :properties ]
+ class << self
- def self.enhance(options)
- options[:verbose] ||= Rake.application.options.trace || false
- fu_check_options options, *OPTIONS + [:output]
+ def enhance(options)
+ fu_check_options options, *OPTIONS + [:output]
+ runtool options.merge(:class=>"org.apache.openjpa.enhance.PCEnhancer", :name=>"Enhancer",
+ :args=>{ "-p"=>options[:properties], "-d"=>options[:output].to_s },
+ :classpath=>options[:classpath])
+ end
- 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 mapping_tool(options)
+ 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
- def self.mapping_tool(options)
- options[:verbose] ||= Rake.application.options.trace || false
- fu_check_options options, *OPTIONS + [:action, :sql]
+ private
- runtool options.merge(:class=>"org.apache.openjpa.jdbc.meta.MappingTool", :name=>"Mapping Tool",
- :args=>{ "-p"=>options[:properties], "-sql"=>options[:sql], "-sa"=>options[:action] })
- end
+ def 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.java *args
+ end
- protected
+ def requires()
+ @required ||= artifacts(REQUIRES).each { |artifact| artifact.invoke }.map(&:to_s)
+ end
- 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
+ end
- def self.requires()
- @required ||= artifacts(REQUIRES).each { |artifact| artifact.invoke }.map(&:to_s)
- end
+ def open_jpa_enhance(options = nil)
+ jpa_options = { :output=>compile.target, :classpath=>[compile.classpath, compile.target.to_s],
+ :properties=>path_to("src/main/resources/META-INF/persistence.xml") }
+ Java::OpenJPA.enhance jpa_options.merge(options || {})
+ end
+ end
end
+ class Project
+ include Java::OpenJPA
+ end
end