public
Description: Clipper O/RM for JRuby
Homepage: http://wiecklabs.com
Clone URL: git://github.com/wiecklabs/clipper.git
clipper / Rakefile
100644 91 lines (77 sloc) 2.389 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require "rubygems"
require "pathname"
require "rake"
require "rake/testtask"
 
# Tests
task :default => [:test]
 
Rake::TestTask.new do |t|
  t.libs << "tests"
  t.test_files = FileList["tests/**/*_test.rb"]
  t.verbose = true
end
 
# Gem
require "rake/gempackagetask"
 
NAME = "clipper"
SUMMARY = "Clipper O/RM"
GEM_VERSION = "0.1.1"
 
spec = Gem::Specification.new do |s|
  s.name = NAME
  s.summary = s.description = SUMMARY
  s.author = "Wieck Media"
  s.email = "dev@wieck.com"
  s.version = GEM_VERSION
  s.platform = Gem::Platform::RUBY
  s.require_path = 'lib'
  s.files = %w(Rakefile) + Dir.glob("lib/**/*")
end
 
Rake::GemPackageTask.new(spec) do |pkg|
  pkg.gem_spec = spec
end
 
desc "Install the Clipper O/RM as a gem"
task :install => [:repackage] do
  sh %{gem install pkg/#{NAME}-#{GEM_VERSION}}
end
 
desc "Publish the Clipper O/RM gem"
task :publish do
  STDOUT.print "Publishing gem... "
  STDOUT.flush
  `ssh gems@gems.wieck.com "cd #{NAME} && git pull &> /dev/null && rake repackage &> /dev/null && cp pkg/* ../site/gems && cd ../site && gem generate_index"`
  STDOUT.puts "done"
end
 
desc "Run performance benchmarks"
task :perf do
  if RUBY_PLATFORM =~ /java/
    sh("jruby -r'lib/clipper' script/performance.rb")
  else
    sh("ruby -r'lib/clipper' script/performance.rb dm")
  end
end
 
desc "Run profiling"
task :profile do
  sh("jruby -r'lib/clipper' -rprofile script/profile.rb")
end
 
namespace :profile do
  desc "Run profiling for get"
  task :get do
    sh("TARGET=get jruby -r'lib/clipper' script/profile/get.rb")
  end
 
  desc "Run profiling for create"
  task :create do
    sh("TARGET=create jruby -r'lib/clipper' script/profile/create.rb")
  end
end
 
def java_classpath_arg # myriad of ways to discover JRuby classpath
    jruby_cpath = ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] &&
      FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
  jruby_cpath ? "-cp #{jruby_cpath}" : ""
end
 
desc "Compile the native Java code."
task :java_compile do
  puts "Compiling native Java code"
  pkg_classes = File.join(*%w(pkg classes))
  jar_name = File.join(*%w(lib clipper_internal.jar))
  mkdir_p pkg_classes
  sh "javac -target 1.5 -source 1.5 -Xlint:unchecked -d pkg/classes #{java_classpath_arg} #{FileList['src/java/**/*.java'].join(' ')}"
  sh "jar cf #{jar_name} -C #{pkg_classes} ."
end
file "lib/clipper_internal.jar" => :java_compile