-
Notifications
You must be signed in to change notification settings - Fork 30
/
Rakefile
121 lines (97 loc) · 3.52 KB
/
Rakefile
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
=begin
JRubyFX - Write JavaFX and FXML in Ruby
Copyright (C) 2013 The JRubyFX Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=end
require 'rubygems'
require 'rubygems/installer'
require 'rubygems/package_task'
require 'rdoc/task'
require_relative 'lib/jrubyfx_tasks'
require_relative 'lib/jrubyfx/version'
task :default => [:install]
jar = ENV['jar'] || "jar"
target = ENV['target'] || "target"
output_jar = ENV['output_jar'] || "jrubyfx-app.jar"
main_script = ENV['main_script'] || nil
src = ENV['src'] || 'src/*'
jruby_version = ENV['jruby_version'] || JRUBY_VERSION || "1.7.1" #if they want speedy raking, use the default so they can use MRI or other rubies
base_dir = File.dirname(__FILE__)
cd base_dir unless Dir.pwd == base_dir
main_script = nil if main_script == "nil"
touch "lib/jrubyfx/core_ext/precompiled.rb" # Get around rake globbing issue
touch "lib/jrubyfx/dsl_map.rb" # Get around rake globbing issue
touch "lib/jrubyfx/imports.rb" # Get around rake globbing issue
desc "Clean all build artifacts except jruby-complete.jar"
task :clean do
rm_rf target if File.exists? target
rm_rf "pkg" if File.exists? "pkg"
rm_rf "doc" if File.exists? "doc"
rm_rf "lib/jrubyfx/core_ext/precompiled.rb"
rm_rf "lib/jrubyfx/dsl_map.rb"
rm_rf "lib/jrubyfx/imports.rb"
end
desc "Clean all build artifacts INCLUDING jruby-complete.jar"
task :clean_jruby => :clean do
rm_rf "#{ENV['HOME']}/.jruby-jar"
end
desc "Precompile all the reflection"
task :reflect do
require 'java' # for java_import
require 'jruby/core_ext' # for the become_java!
# generate imports file
$WRITE_OUT = File.read("lib/jrubyfx/part_imports.rb")
$WRITE_OUT = $WRITE_OUT[0..$WRITE_OUT.index('###### IMPORTANT LINE #####')]
$WRITE_OUT << "\n\n # The below lines are generated by `rake reflect`. Do not edit.\n\n"
require_relative 'lib/jrubyfx/part_imports'
File.open("lib/jrubyfx/imports.rb", "w") do |out|
out << $WRITE_OUT
$WRITE_OUT = nil
out << <<ENDL
end
end
ENDL
end
require_relative 'reflect_generator'
end
desc "Run a script without installing the gem"
task :run => :reflect do
ruby "-I lib '#{main_script||'samples/fxml/Demo.rb'}'"
end
task :gem => :reflect
# The gemspec exports the global $spec variable for us
load 'jrubyfx.gemspec'
Gem::PackageTask.new($spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end
desc "Build and install the gem"
task :install => :gem do
Gem::Installer.new("pkg/jrubyfx-#{JRubyFX::VERSION}-java.gem").install
end
task :download_jruby_jar do
JRubyFX::Tasks::download_jruby(jruby_version)
end
desc "Create a full jar with embedded JRuby and given script (via main_script and src ENV var)"
task :jar => [:clean, :download_jruby_jar, :precompile] do
JRubyFX::Tasks::jarify_jrubyfx(src, main_script, target, output_jar, jar: jar)
end
desc "Create a full jar and run it"
task :run_jar => :jar do
sh "java -jar #{target}/#{output_jar}"
end
RDoc::Task.new do |rdoc|
files = ['lib'] # FIXME: readme and markdown
rdoc.rdoc_files.add(files)
rdoc.main = "README.md"
rdoc.title = "JRubyFX Docs"
rdoc.rdoc_dir = 'doc/'
end