lib/jrubyfx_tasks.rb
##
# 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
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
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
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
      opts = {file_filter: ->(f){true},jar: "jar"}.merge(opts)
      mkdir_p target
      cp "#{ENV['HOME']}/.jruby-jar/jruby-complete-#{opts[:version] || JRUBY_VERSION}.jar", "#{target}/#{output_jar}"
      FileList[src].each do |iv_srv|
        cp_r iv_srv, "#{target}/#{File.basename(iv_srv)}" if (main_script == nil || main_script != iv_srv) && opts[:file_filter].call(iv_srv)
      end
	cp_r "./.jrubyfx_cache", "#{target}/.jrubyfx_cache"
      cp main_script, "#{target}/jar-bootstrap.rb" unless main_script == nil
      unless File.exists? "#{target}/jar-bootstrap.rb"
        $stderr.puts "@"*79
        $stderr.puts "@#{"!!!WARNING!!!".center(79-2)}@"
        $stderr.puts "@#{"jar-bootstrap.rb NOT FOUND!".center(79-2)}@"
        $stderr.puts "@#{"Did you set main_src= or have jar-bootstrap in src= ?".center(79-2)}@"
        $stderr.puts "@"*79
      end
      FileList["#{File.dirname(__FILE__)}/*"].each do |librb|
        cp_r librb, target
      end
      fxml_loader_path = nil
      $LOAD_PATH.each do |pth|
        if File.exist? File.join(pth, "jrubyfx-fxmlloader.rb")
          fxml_loader_path = pth
          break
        end
      end
      unless fxml_loader_path
        fxml_loader_path = File.join(Gem::Specification.find_by_path('jrubyfx-fxmlloader').full_gem_path, "lib")
      end
      FileList["#{fxml_loader_path}/*"].each do |librb|
        cp_r librb, target
      end
      base_dir = Dir.pwd
      cd target
      sh "#{opts[:jar]} ufe '#{output_jar}' org.jruby.JarBootstrapMain * .jr*"
      chmod 0775, output_jar
      cd base_dir
      if target_was_nil
        mv "#{target}/#{output_jar}", final_jar
        rm_rf target
      end
    end
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 opts = { file_filter : -> ( f ) { true } , jar : "jar" } . merge ( opts ) mkdir_p target cp "#{ENV['HOME']}/.jruby-jar/jruby-complete-#{opts[:version] || JRUBY_VERSION}.jar" , "#{target}/#{output_jar}" FileList [ src ] . each do | iv_srv | cp_r iv_srv , "#{target}/#{File.basename(iv_srv)}" if ( main_script == nil || main_script != iv_srv ) && opts [ :file_filter ] . call ( iv_srv ) end cp_r "./.jrubyfx_cache" , "#{target}/.jrubyfx_cache" cp main_script , "#{target}/jar-bootstrap.rb" unless main_script == nil unless File . exists? "#{target}/jar-bootstrap.rb" $stderr . puts "@" * 79 $stderr . puts "@#{"!!!WARNING!!!".center(79-2)}@" $stderr . puts "@#{"jar-bootstrap.rb NOT FOUND!".center(79-2)}@" $stderr . puts "@#{"Did you set main_src= or have jar-bootstrap in src= ?".center(79-2)}@" $stderr . puts "@" * 79 end FileList [ "#{File.dirname(__FILE__)}/*" ] . each do | librb | cp_r librb , target end fxml_loader_path = nil $LOAD_PATH . each do | pth | if File . exist? File . join ( pth , "jrubyfx-fxmlloader.rb" ) fxml_loader_path = pth break end end unless fxml_loader_path fxml_loader_path = File . join ( Gem :: Specification . find_by_path ( 'jrubyfx-fxmlloader' ) . full_gem_path , "lib" ) end FileList [ "#{fxml_loader_path}/*" ] . each do | librb | cp_r librb , target end base_dir = Dir . pwd cd target sh "#{opts[:jar]} ufe '#{output_jar}' org.jruby.JarBootstrapMain * .jr*" chmod 0775 , output_jar cd base_dir if target_was_nil mv "#{target}/#{output_jar}" , final_jar rm_rf target end end
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.
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 .
# set defaults #copy jruby jar file in, along with script and our rb files #copy source in #copy our libs in # this will find it if we are calling ruby -I whatever # default to gems #copy fxmlloader in # edit the jar
src
<not_specific>
main_script
<not_specific>
target
<not_specific>
output_jar
<not_specific>
opts
<not_specific>