Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Issue #150 - compile roxy into a jar
Browse files Browse the repository at this point in the history
added ./ml jar
  • Loading branch information
paxtonhare committed Dec 9, 2013
1 parent a7cd1ff commit 39ab965
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions deploy/lib/Help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,20 @@ def self.capture
DOC
end

def self.jar
<<-DOC.strip_heredoc
Usage: ml jar
General options:
-v, [--verbose] # Verbose output
Prerequisites:
- You must be running JRuby http://jruby.org/
- You must have the warbler gem installed
> gem install warbler
DOC
end

def self.doHelp(logger, command, error_message = nil)
logger.error "#{error_message}\n" if error_message
logger.info Help.send(command)
Expand Down
28 changes: 28 additions & 0 deletions deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,34 @@ def ServerConfig.expand_path(path)
return result
end

def self.jar
raise HelpException.new("jar", "You must be using JRuby to create a jar") unless RUBY_PLATFORM == "java"
begin
# ensure warbler gem is installed
gem 'warbler'
require 'warbler'

jar_file = ServerConfig.expand_path("#{@@path}/../roxy.jar")
logger.debug(jar_file)
Dir.mktmpdir do |tmp_dir|
logger.debug(tmp_dir)

FileUtils.mkdir_p tmp_dir + "/bin"
FileUtils.cp(ServerConfig.expand_path("#{@@path}/lib/ml.rb"), tmp_dir + "/bin/roxy.rb")

FileUtils.cp_r(ServerConfig.expand_path("#{@@path}/lib"), tmp_dir)
FileUtils.cp(ServerConfig.expand_path("#{@@path}/app_specific.rb"), tmp_dir + "/lib/app_specific.rb")

Dir.chdir(tmp_dir) do
Warbler::Application.new.run
FileUtils.cp(Dir.glob("*.jar")[0], jar_file)
end
end
rescue Gem::LoadError
raise HelpException.new("jar", "Please install the warbler gem")
end
end

def self.init
sample_config = ServerConfig.expand_path("#{@@path}/sample/ml-config.sample.xml")
sample_properties = ServerConfig.expand_path("#{@@path}/sample/build.sample.properties")
Expand Down

0 comments on commit 39ab965

Please sign in to comment.