jrmvnrunner 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/jrmvnrun CHANGED
@@ -7,8 +7,12 @@ case command
7
7
  when "exec"
8
8
  cmd = args.shift
9
9
  Jrmvnrunner.init!(Dir.pwd, cmd, args)
10
+ when "install"
11
+ Jrmvnrunner.install!(Dir.pwd)
10
12
  when "help"
11
- puts "jrmvnrun exec [COMMAND]"
13
+ puts "Available options are: exec, install"
14
+ puts "INSTALL: jrmvnrun install - forces Jrmvnrunner to clean the cache"
15
+ puts "EXEC: jrmvnrun exec [COMMAND] - executes the COMMAND with classpath"
12
16
  else
13
17
  puts "Unknown command '#{command}'! Exec jrmvnrun help to see the options!"
14
18
  end
@@ -22,11 +22,17 @@ module Jrmvnrunner
22
22
  def execute!
23
23
  log "Current directory: #{Dir.pwd}"
24
24
 
25
- ensure_jruby!
26
- write_gem!
27
- ensure_bundle!
28
- write_pom!
29
- maven_build!
25
+ if cached_dir.nil?
26
+ ensure_jruby!
27
+ ensure_mvn!
28
+ write_gem!
29
+ ensure_bundle!
30
+ write_pom!
31
+ maven_build!
32
+ create_cache_file!
33
+ else
34
+ @tmpdir = cached_dir
35
+ end
30
36
 
31
37
  if @cmd
32
38
  # Generating command and exec...
@@ -44,6 +50,10 @@ module Jrmvnrunner
44
50
  end
45
51
  end
46
52
 
53
+ def clean_cache!
54
+ File.unlink(cache_file) if File.exists?(cache_file)
55
+ end
56
+
47
57
  private
48
58
 
49
59
  def cfg_file
@@ -81,6 +91,20 @@ module Jrmvnrunner
81
91
  %Q{-J-cp "#{cp}"}
82
92
  end
83
93
 
94
+ def cache_file
95
+ root.join(".Jrmvnrunner.cache")
96
+ end
97
+
98
+ def cached_dir
99
+ (File.exists?(cache_file)) ? File.read(cache_file).strip : nil
100
+ end
101
+
102
+ def create_cache_file!
103
+ File.open(cache_file, "w+") do |f|
104
+ f.write(tmpdir)
105
+ end
106
+ end
107
+
84
108
  def jar_files
85
109
  Dir[Pathname.new(build_dir).join("#{@opts[:project][:name]}", "*.jar")]
86
110
  end
@@ -97,6 +121,11 @@ module Jrmvnrunner
97
121
  raise "Cannot find valid JRuby installation (tried command '#{which_cmd} jruby')!" if cmd_path("jruby").nil?
98
122
  end
99
123
 
124
+ def ensure_mvn!
125
+ # Building Maven dependencies...
126
+ raise "Cannot find valid Maven installation (tried command '#{which_cmd} mvn')!" if cmd_path("mvn").nil?
127
+ end
128
+
100
129
  def ensure_bundle!
101
130
  unless gems_list =~ /bundler/
102
131
  log "Installing bundler..."
@@ -109,8 +138,6 @@ module Jrmvnrunner
109
138
  end
110
139
 
111
140
  def maven_build!
112
- # Building Maven dependencies...
113
- raise "Cannot find valid Maven installation (tried command '#{which_cmd} mvn')!" if cmd_path("mvn").nil?
114
141
  log "Building dependencies..."
115
142
  build_res = `"#{cmd_path("mvn")}" -f #{pom_file} clean install`
116
143
  raise "Cannot build project: \n #{build_res}" unless build_res =~ /BUILD SUCCESS/
@@ -167,11 +194,6 @@ module Jrmvnrunner
167
194
  end
168
195
  end
169
196
 
170
- def remove_gem_and_pom!
171
- File.unlink(gem_file)
172
- File.unlink(pom_file)
173
- end
174
-
175
197
  def generate_pom
176
198
  <<-XML
177
199
  <?xml version="1.0" encoding="UTF-8"?>
data/lib/jrmvnrunner.rb CHANGED
@@ -1,35 +1,50 @@
1
1
  require 'pathname'
2
2
 
3
3
  module Jrmvnrunner
4
- VERSION="0.1.3"
4
+ VERSION="0.1.4"
5
5
  MYDIR = Pathname.new(File.dirname(File.expand_path(__FILE__)))
6
6
  autoload :Runner, MYDIR.join('jrmvnrunner/runner')
7
7
  autoload :Dsl, MYDIR.join('jrmvnrunner/dsl')
8
8
 
9
+ def self.install!(wdir = Dir.pwd)
10
+ root = Pathname.new(wdir)
11
+ runnerfile = root.join("Jrmvnrunner")
12
+ if File.exists?(runnerfile)
13
+ runner = init_runner(root, runnerfile)
14
+ runner.clean_cache!
15
+ runner.execute!
16
+ end
17
+ end
18
+
9
19
  def self.init!(wdir = Dir.pwd, cmd = nil, args = [])
10
20
  raise "Jrmvnrunner has been already started!" if @__init_called
11
21
  @__init_called = true
12
22
  root = Pathname.new(wdir)
13
-
14
23
  runnerfile = root.join("Jrmvnrunner")
15
24
  if File.exists?(runnerfile)
16
- dsl = Dsl.new
17
- runner_conf = File.read(runnerfile)
25
+ runner = init_runner(root, runnerfile, cmd, args)
26
+ runner.execute!
27
+ end
28
+ end
18
29
 
19
- dsl.instance_exec do
20
- eval(runner_conf.match(/(project .+)\n/)[1])
21
- end
30
+ private
22
31
 
23
- dsl.Pomfile(runner_conf.match(/Pomfile\s+do\s(.+?)end/m)[1])
24
- dsl.Gemfile(runner_conf.match(/Gemfile\s+do\s(.+?)end/m)[1])
25
- runner = Runner.new(cmd, {
26
- :gem => dsl.gem,
27
- :pom => dsl.pom,
28
- :project => dsl.project_info,
29
- :root => root,
30
- :args => args
31
- })
32
- runner.execute!
32
+ def self.init_runner(root = Dir.pwd, runnerfile = root.join("Jrmvnrunner"), cmd = nil, args = [])
33
+ dsl = Dsl.new
34
+ runner_conf = File.read(runnerfile)
35
+
36
+ dsl.instance_exec do
37
+ eval(runner_conf.match(/(project .+)\n/)[1])
33
38
  end
39
+
40
+ dsl.Pomfile(runner_conf.match(/Pomfile\s+do\s(.+?)end/m)[1])
41
+ dsl.Gemfile(runner_conf.match(/Gemfile\s+do\s(.+?)end/m)[1])
42
+ Runner.new(cmd, {
43
+ :gem => dsl.gem,
44
+ :pom => dsl.pom,
45
+ :project => dsl.project_info,
46
+ :root => root,
47
+ :args => args
48
+ })
34
49
  end
35
50
  end
metadata CHANGED
@@ -1,50 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrmvnrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ prerelease:
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ilya Sadykov
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
16
+ version_requirements: !ruby/object:Gem::Requirement
18
17
  requirements:
19
- - - ~>
18
+ - - "~>"
20
19
  - !ruby/object:Gem::Version
21
20
  version: 2.10.0
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
21
  none: false
22
+ requirement: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.10.0
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sourcify
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
32
+ version_requirements: !ruby/object:Gem::Requirement
34
33
  requirements:
35
- - - ! '>='
34
+ - - ">="
36
35
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
36
+ version: !binary |-
37
+ MA==
41
38
  none: false
39
+ requirement: !ruby/object:Gem::Requirement
42
40
  requirements:
43
- - - ! '>='
41
+ - - ">="
44
42
  - !ruby/object:Gem::Version
45
- version: '0'
46
- description: This gem allows you to specify the jar-dependencies of your project and
47
- run your tasks with the classpath
43
+ version: !binary |-
44
+ MA==
45
+ none: false
46
+ prerelease: false
47
+ type: :runtime
48
+ description: This gem allows you to specify the jar-dependencies of your project and run your tasks with the classpath
48
49
  email: smecsia@gmail.com
49
50
  executables:
50
51
  - jrmvnrun
@@ -60,26 +61,28 @@ files:
60
61
  - README.md
61
62
  homepage: ''
62
63
  licenses: []
63
- post_install_message:
64
+ post_install_message:
64
65
  rdoc_options: []
65
66
  require_paths:
66
67
  - lib
67
68
  required_ruby_version: !ruby/object:Gem::Requirement
68
- none: false
69
69
  requirements:
70
- - - ! '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: '0'
73
- required_rubygems_version: !ruby/object:Gem::Requirement
72
+ version: !binary |-
73
+ MA==
74
74
  none: false
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  requirements:
76
- - - ! '>='
77
+ - - ">="
77
78
  - !ruby/object:Gem::Version
78
- version: '0'
79
+ version: !binary |-
80
+ MA==
81
+ none: false
79
82
  requirements: []
80
- rubyforge_project:
81
- rubygems_version: 1.8.23
82
- signing_key:
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.24
85
+ signing_key:
83
86
  specification_version: 3
84
87
  summary: Simple lib to execute jruby task with the java classpath
85
88
  test_files: []