Class: Jrmvnrunner::Runner
- Inherits:
-
Object
- Object
- Jrmvnrunner::Runner
- Defined in:
- lib/jrmvnrunner/runner.rb
Instance Method Summary collapse
- #clean_cache! ⇒ Object
- #execute! ⇒ Object
-
#initialize(cmd = nil, opts = {}) ⇒ Runner
constructor
A new instance of Runner.
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
#clean_cache! ⇒ Object
53 54 55 |
# File 'lib/jrmvnrunner/runner.rb', line 53 def clean_cache! File.unlink(cache_file) if File.exists?(cache_file) end |
#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 46 47 48 49 50 51 |
# File 'lib/jrmvnrunner/runner.rb', line 22 def execute! log "Current directory: #{Dir.pwd}" if cached_dir.nil? || !File.exists?(cached_dir) ensure_jruby! ensure_mvn! write_gem! ensure_bundle! write_pom! maven_build! create_cache_file! else @tmpdir = cached_dir end 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 |