Module: JRubyFX::Tasks
- Extended by:
- Rake::DSL
- Defined in:
- lib/jrubyfx_tasks.rb
Overview
This module contains utilities to jarify an app, and can be used in a rakefile or a running app.
Constant Summary collapse
- BASE_URL =
Base URL of JRuby-complete.jar download location
'http://repository.codehaus.org/org/jruby/jruby-complete'
Class Method Summary collapse
-
.download(version_string) ⇒ Object
:nodoc:.
-
.download_jruby(jruby_version, force = false) ⇒ Object
Downloads the jruby-complete jar file for
jruby_versionand save in ~/.jruby-jar/jruby-complete.jar unless it already exits. -
.jarify_jrubyfx(src = "src/*", main_script = nil, target = "target", output_jar = "jrubyfx-app.jar", opts = {}) ⇒ Object
Creates a full jar from the given source pattern (must be a pattern to match files), with the given main script as the script to launch when the jarfile is run.
Class Method Details
.download(version_string) ⇒ Object
:nodoc:
100 101 102 103 104 |
# File 'lib/jrubyfx_tasks.rb', line 100 def download(version_string) #:nodoc: File.open("jruby-complete.jar","wb") do |f| f.write(open("#{BASE_URL}/#{version_string}/jruby-complete-#{version_string}.jar").read) end end |
.download_jruby(jruby_version, force = false) ⇒ Object
Downloads the jruby-complete jar file for jruby_version and save in ~/.jruby-jar/jruby-complete.jar unless it already exits. If the jar is corrupt or an older version, set force to true to delete and re-download
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jrubyfx_tasks.rb', line 34 def download_jruby(jruby_version, force=false) dist = "#{ENV['HOME']}/.jruby-jar" unless force || (File.exists?("#{dist}/jruby-complete.jar") && File.size("#{dist}/jruby-complete.jar") > 0) mkdir_p dist base_dir = Dir.pwd cd dist puts "JRuby complete jar not found. Downloading... (May take awhile)" download(jruby_version) cd base_dir end end |
.jarify_jrubyfx(src = "src/*", main_script = nil, target = "target", output_jar = "jrubyfx-app.jar", opts = {}) ⇒ Object
Creates a full jar from the given source pattern (must be a pattern to match files), with the given main script as the script to launch when the jarfile is run. The output jar is saved in the target dir, which also doubles as a temporary work dir. jar is the executable that makes jars. If target is nill then a random temporary directory is created, and output_jar is the full path to the jar file to save
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 |
# File 'lib/jrubyfx_tasks.rb', line 53 def jarify_jrubyfx(src="src/*" ,main_script=nil, target="target", output_jar="jrubyfx-app.jar", opts = {}) if target_was_nil = target == nil target = Dir.mktmpdir("jrubyfx") final_jar = output_jar output_jar = File.basename output_jar end # set defaults opts = {file_filter: ->(f){true},jar: "jar"}.merge(opts) mkdir_p target #copy jruby jar file in, along with script and our rb files cp "#{ENV['HOME']}/.jruby-jar/jruby-complete.jar", "#{target}/#{output_jar}" #copy source in FileList[src].each do |iv_srv| cp iv_srv, "#{target}/#{File.basename(iv_srv)}" if (main_script == nil || main_script != iv_srv) && opts[:file_filter].call(iv_srv) end cp main_script, "#{target}/jar-bootstrap.rb" unless main_script == nil unless File.exists? "#{target}/jar-bootstrap.rb" puts "@"*79 puts "@#{"!!!WARNING!!!".center(79-2)}@" puts "@#{"jar-bootstrap.rb NOT FOUND!".center(79-2)}@" puts "@#{"Did you set main_src= or have jar-bootstrap in src= ?".center(79-2)}@" puts "@"*79 end #copy our libs in FileList["#{File.dirname(__FILE__)}/*"].each do |librb| cp_r librb, target end # edit the jar base_dir = Dir.pwd cd target sh "#{opts[:jar]} ufe '#{output_jar}' org.jruby.JarBootstrapMain *" chmod 0775, output_jar cd base_dir if target_was_nil mv "#{target}/#{output_jar}", final_jar rm_rf target end end |