public
Description:
Homepage: http://qtjruby.org
Clone URL: git://github.com/nmerouze/qtjruby-core.git
nmerouze (author)
Tue Jan 06 03:39:35 -0800 2009
commit  b3c1613f6db454cf83a8dd6ef02cfb68a5609276
tree    d0284e5f15fe3b9987fbfb97f6c5b2811c62099c
parent  658911277e5a7b87c8c5f5a74893dafdc2672038
qtjruby-core / Rakefile
100644 78 lines (66 sloc) 2.341 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
require 'rake'
require 'rake/gempackagetask'
 
windows = (ENV_JAVA['os.name'] =~ /Windows/) rescue nil
SUDO = windows ? "" : "sudo"
 
NAME = 'qtjruby-core'
 
require "lib/qtjruby-core/version"
 
task :default => [:build, :install]
 
spec = Gem::Specification.new do |s|
  s.name = NAME
  s.version = Qt::JRuby::VERSION
  s.platform = "java"
  s.author = "Nicolas Merouze"
  s.email = "nicolas.merouze@gmail.com"
  s.summary = "Qt meets Java meets Ruby."
  s.bindir = "bin"
  s.executables = %w( qtjruby )
  s.description = s.summary
  s.require_path = "lib"
  s.files = %w( LICENSE README.textile Rakefile TODO ) + Dir["{bin,lib}/**/*"]
 
  # rdoc
  s.has_rdoc = true
  s.extra_rdoc_files = ["LICENSE", "README.textile"]
  
  # Dependencies
  s.add_dependency "extlib", "~>0.9.9"
end
 
Rake::GemPackageTask.new(spec) do |package|
  package.gem_spec = spec
end
 
task :build do
  sh %{ant -lib #{ENV_JAVA['jruby.home']}/lib}
end
 
task :install => :package do
  sh %{#{SUDO} #{ENV_JAVA['jruby.home']}/bin/jruby -S gem install --local pkg/#{NAME}-#{Qt::JRuby::VERSION}-java.gem --no-update-sources}
end
 
namespace :github do
  desc "Update Github Gemspec"
  task :update_gemspec do
    skip_fields = %w(new_platform original_platform)
    integer_fields = %w(specification_version)
    
    result = "Gem::Specification.new do |s|\n"
    spec.instance_variables.each do |ivar|
      value = spec.instance_variable_get(ivar)
      name = ivar.split("@").last
      next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
      if name == "dependencies"
        value.each do |d|
          dep, *ver = d.to_s.split(" ")
          result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
        end
      else
        case value
        when Array
          value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
        when String
          value = value.to_i if integer_fields.include?(name)
          value = value.inspect
        else
          value = value.to_s.inspect
        end
        result << " s.#{name} = #{value}\n"
      end
    end
    result << "end"
    File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
  end
end