Class: Jrmvnrunner::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/jrmvnrunner/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(cmd = nil, opts = {}) ⇒ Runner

Returns a new instance of Runner.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jrmvnrunner/runner.rb', line 9

def initialize(cmd = nil, opts={})
  @args = opts[:args] || []
  @opts = opts
  @pom = opts[:pom] || Dsl::Pom.new
  @gem = opts[:gem] || Dsl::Gem.new
  @root = opts[:root] || root
  @cmd = cmd
  @tmpdir = opts[:tmpdir]
  @config = YAML::load(File.read(cfg_file)) if File.exists?(cfg_file)
  @config ||= {}
  @opts[:project] ||= {:group_id => 'test', :artifact_id => 'test', :version => '0.1-SNAPSHOT'}
end

Instance Method Details

#execute!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jrmvnrunner/runner.rb', line 22

def execute!
  log "Current directory: #{Dir.pwd}"

  ensure_jruby!
  write_gem!
  ensure_bundle!
  write_pom!
  maven_build!

  if @cmd
    # Generating command and exec...
    ensure_cmd!
    cmd=%Q["#{cmd_path("jruby")}" #{cp_string} #{jruby_opts} "#{cmd_path(@cmd)}" #{@args.join(" ")}]
    log "Executing '#{cmd}'..."
    exec cmd
  else
    require 'java'
    ENV['BUNDLE_GEMFILE'] = gem_file
    require 'bundler'
    Bundler.definition.validate_ruby!
    Bundler.load.setup_environment
    jar_files.each { |jf| require jf }
  end
end