You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2007/05/03 02:50:24 UTC
svn commit: r534668 - /incubator/ode/trunk/tasks/derby.rake
Author: assaf
Date: Wed May 2 17:50:23 2007
New Revision: 534668
URL: http://svn.apache.org/viewvc?view=rev&rev=534668
Log:
Fixed Derby task to use AntWrap.
Modified:
incubator/ode/trunk/tasks/derby.rake
Modified: incubator/ode/trunk/tasks/derby.rake
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/tasks/derby.rake?view=diff&rev=534668&r1=534667&r2=534668
==============================================================================
--- incubator/ode/trunk/tasks/derby.rake (original)
+++ incubator/ode/trunk/tasks/derby.rake Wed May 2 17:50:23 2007
@@ -4,6 +4,8 @@
REQUIRES = Buildr.group("derby", "derbytools", :under=>"org.apache.derby", :version=>"10.1.2.1")
+ Java.rjb.onload { Java.rjb.classpath << REQUIRES }
+
class << self
# Returns a task that will create a new Derby database. The task name is the path to
@@ -13,24 +15,16 @@
# Derby.create "mydb"=>derby.sql
def create(args)
db, prereqs = Rake.application.resolve_args(args)
- # Copy the SQL files into the database directory.
file(File.expand_path(db)=>prereqs) do |task|
- cmd = [ Java.path_to_bin('java'), "-cp", requires, "org.apache.derby.tools.ij" ]
- Open3.popen3(*cmd) do |stdin, stdout, stderr|
- # Shutdown so if a database already exists, we can remove it.
- stdin.puts "connect 'jdbc:derby:;shutdown=true';"
- rm_rf task.name if File.exist?(task.name)
- # Create a new database, and load all the prerequisites.
- stdin.puts "connect 'jdbc:derby:#{task.to_s};create=true;user=sa'"
- stdin.puts "set schema sa"
- stdin.puts "autocommit on;"
- task.prerequisites.each { |prereq| stdin.write File.read(prereq.to_s) }
- # Exiting will shutdown the database so we can copy the files around.
- stdin.puts "exit"
- stdin.close
- # Helps when dignosing SQL errors.
- stdout.read.tap { |output| puts output if Rake.application.options.trace }
+ rm_rf task.name if File.exist?(task.name)
+ Ant.executable("derby") do |ant|
+ sqls = task.prerequisites.map(&:to_s)
+ ant.sql :driver=>"org.apache.derby.jdbc.EmbeddedDriver", :url=>"jdbc:derby:#{task.to_s};create=true",
+ :userid=>"sa", :password=>"", :autocommit=>"on" do
+ sqls.each { |sql| transaction :src=>sql }
+ end
end
+ # Copy the SQL files into the database directory.
Buildr.filter(prereqs).into(task.name).run
touch task.name, :verbose=>false
end