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-#{opts[:version] || JRUBY_VERSION}.jar", "#{target}/#{output_jar}"

      #copy source in
      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 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

      #copy our libs in
      FileList["#{File.dirname(__FILE__)}/*"].each do |librb|
        cp_r librb, target
      end

      fxml_loader_path = nil
      # this will find it if we are calling ruby -I whatever
      $LOAD_PATH.each do |pth|
        if File.exist? File.join(pth, "jrubyfx-fxmlloader.rb")
          fxml_loader_path = pth
          break
        end
      end

      # default to gems
      unless fxml_loader_path
        fxml_loader_path = File.join(Gem::Specification.find_by_path('jrubyfx-fxmlloader').full_gem_path, "lib")
      end
      #copy fxmlloader in
      FileList["#{fxml_loader_path}/*"].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
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-#{opts[:version] || JRUBY_VERSION}.jar", "#{target}/#{output_jar}"

      #copy source in
      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 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

      #copy our libs in
      FileList["#{File.dirname(__FILE__)}/*"].each do |librb|
        cp_r librb, target
      end

      fxml_loader_path = nil
      # this will find it if we are calling ruby -I whatever
      $LOAD_PATH.each do |pth|
        if File.exist? File.join(pth, "jrubyfx-fxmlloader.rb")
          fxml_loader_path = pth
          break
        end
      end

      # default to gems
      unless fxml_loader_path
        fxml_loader_path = File.join(Gem::Specification.find_by_path('jrubyfx-fxmlloader').full_gem_path, "lib")
      end
      #copy fxmlloader in
      FileList["#{fxml_loader_path}/*"].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
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