Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 80103301eb
Fetching contributors…

Cannot retrieve contributors at this time

executable file 89 lines (73 sloc) 2.614 kb
#!/usr/bin/env ruby
# vim:set filetype=ruby:
require "pathname"
require "optparse"
options = { :interactive => false }
parser = OptionParser.new do |opts|
opts.banner = "Usage: akephalos [--interactive, --use-htmlunit-snapshot] | [--server] <port>"
opts.on("-s", "--server", "Run in server mode (default)")
opts.on("-i", "--interactive", "Run in interactive mode") { options[:interactive] = true }
opts.on("--use-htmlunit-snapshot", "Use the snapshot of htmlunit") { options[:use_htmlunit_snapshot] = true }
opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
end
parser.parse!
root = Pathname(__FILE__).expand_path.dirname.parent
lib = root + 'lib'
src = root + 'src'
case
when options[:use_htmlunit_snapshot]
require "fileutils"
FileUtils.mkdir_p("vendor/htmlunit")
Dir["vendor/htmlunit/*.jar"].each { |jar| File.unlink(jar) }
Dir.chdir("vendor") do
$stdout.print "Downloading latest snapshot... "
$stdout.flush
%x[curl -O http://build.canoo.com/htmlunit/artifacts/htmlunit-2.9-SNAPSHOT-with-dependencies.zip &> /dev/null]
puts "done"
$stdout.print "Extracting dependencies... "
$stdout.flush
%x[unzip -j -d htmlunit htmlunit-2.9-SNAPSHOT-with-dependencies.zip htmlunit-2.9-SNAPSHOT/lib htmlunit-2.9-SNAPSHOT/lib/* &> /dev/null]
puts "done"
File.unlink "htmlunit-2.9-SNAPSHOT-with-dependencies.zip"
end
$stdout.puts "="*40
$stdout.puts "The latest HtmlUnit snapshot has been extracted to vendor/htmlunit!"
when options[:interactive]
$:.unshift('vendor', lib, src)
require 'rubygems'
require 'akephalos'
require 'akephalos/console'
Akephalos::Console.start
else
unless port = ARGV[0]
puts parser.help
exit
end
if RUBY_PLATFORM == "java"
$:.unshift("vendor", lib, src)
require 'akephalos/server'
Akephalos::Server.start!(port)
else
require 'rubygems'
require 'jruby-jars'
jruby = JRubyJars.core_jar_path
jruby_stdlib = JRubyJars.stdlib_jar_path
java_args = [
"-Xmx128M",
"-cp", [JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path].join(":"),
"org.jruby.Main"
]
ruby_args = [
"-Ku",
"-I", "vendor:#{lib}:#{src}",
"-r", "akephalos/server",
"-e", "Akephalos::Server.start!(#{port.inspect})"
]
# Bundler sets ENV["RUBYOPT"] to automatically load bundler/setup.rb, but
# since the akephalos server doesn't have any gem dependencies and is
# always executed with the same context, we clear RUBYOPT before running
# exec.
ENV["RUBYOPT"] = ""
exec("java", *(java_args + ruby_args))
end
end
Jump to Line
Something went wrong with that request. Please try again.