mvn2chain 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac1eea8e6fe9fcc49d5d131c8f6d607c2abdc6fb
4
+ data.tar.gz: 8cfeed1c044f8a689719e70d6cc75e8e252fb134
5
+ SHA512:
6
+ metadata.gz: 6159147ea14872ab877316d27d7899a6bdf7e7f0522920aae59aaa928b19706e58eade227d518f50e839675f08526164b1b069a2e5e7ff56d262893400a29487
7
+ data.tar.gz: b5edbec3034ff737820fec44de941fcb3ba835b478f6622065bfea4c630883d61fa6887a9aa514310a59f84d5a770476965c18cda2f0be29b79f5df4519a3272
data/.gitignore ADDED
@@ -0,0 +1,28 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
24
+ /.idea/
25
+
26
+ /deps.mvn2chain.yaml
27
+
28
+ /build.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mvn2chain.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Eric Henderson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Mvn2chain
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mvn2chain'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mvn2chain
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/mvn2chain/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/mvn2chain ADDED
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require 'thor'
5
+ require 'everyday_thor_util'
6
+ require 'everyday-plugins'
7
+
8
+ EverydayThorUtil::SubCommandTypes.def_types(:command_ids, :flag, :command, :helper)
9
+
10
+ module Mvn2Chain
11
+ class DataStore
12
+ class << self
13
+ attr_accessor :autosave
14
+
15
+ def deps=(deps)
16
+ @deps = deps
17
+ self.save if self.autosave
18
+ end
19
+
20
+ def deps
21
+ @deps ||= load
22
+ end
23
+
24
+ def load
25
+ @deps = File.exist?('deps.mvn2chain.yaml') ? YAML::load_file('deps.mvn2chain.yaml') : {}
26
+ end
27
+
28
+ def save
29
+ IO.write('deps.mvn2chain.yaml', self.deps.to_yaml)
30
+ end
31
+ end
32
+ class << self.deps
33
+ attr_accessor :data_store
34
+
35
+ alias :old_assign :[]=
36
+
37
+ def []=(id, dep)
38
+ old_assign(id, dep)
39
+ self.data_store.save if self.data_store.autosave
40
+ self
41
+ end
42
+
43
+ alias :old_delete :delete
44
+
45
+ def delete(id, &block)
46
+ v = old_delete(id, &block)
47
+ self.data_store.save if self.data_store.autosave
48
+ v
49
+ end
50
+ end
51
+ self.deps.data_store = self
52
+ self.autosave = true
53
+ end
54
+
55
+ class Commands
56
+ extend Plugin
57
+
58
+ register(:command, id: :path, parent: nil, name: 'path', short_desc: 'path', desc: 'print out the path of the current file') { puts __FILE__ }
59
+
60
+ register(:command, id: :dep, parent: nil, name: 'dep', aliases: %w(deps dependency dependencies), short_desc: 'dep SUBCOMMAND ARGS...', desc: 'alter the stored dependencies')
61
+
62
+ register(:command, id: :dep_list, parent: :dep, aliases: %w(ls), name: 'list', short_desc: 'list', desc: 'print out the list of dependencies') {
63
+ deps = DataStore.deps
64
+ if deps.empty?
65
+ puts 'No dependencies registered'
66
+ else
67
+ puts 'Dependencies:'
68
+ max_id_len = deps.keys.map { |v| v.length }.max
69
+ deps.each { |v| puts "#{' ' * 4}#{v[0]}#{' ' * (max_id_len + 4 - v[0].length)}=> #{v[1]}" }
70
+ end
71
+ }
72
+
73
+ register(:command, id: :dep_add, parent: :dep, name: 'add', aliases: %w(register reg), short_desc: 'add DEP_ID DEP', desc: 'add a dependency to the list') { |dep_id, dep|
74
+ path = File.expand_path(dep)
75
+ if File.exist?(path)
76
+ if File.directory?(path)
77
+ if File.exist?(File.expand_path('pom.xml', path)) || options[:force]
78
+ if DataStore.deps.keys.include?(dep_id) && !options[:force]
79
+ puts "Dependency ID '#{dep_id}' is already in use. Use the -f / --force option to overwrite it"
80
+ elsif DataStore.deps.values.include?(path)
81
+ path_id = DataStore.deps.invert[path]
82
+ puts "Path '#{path}' is already registered under the dependency ID '#{path_id}'"
83
+ else
84
+ DataStore.deps[dep_id] = path
85
+ puts "Added dependency '#{dep_id}' => '#{path}'"
86
+ end
87
+ else
88
+ puts "Could not find pom.xml at path '#{path}'. If this is still a valid maven root, use the -f/--force option"
89
+ end
90
+ else
91
+ puts "Path '#{path}' is not a directory. Please provide a maven root directory"
92
+ end
93
+ else
94
+ puts "Path '#{dep}' does not seem to exist. Please check that you entered it correctly"
95
+ end
96
+ }
97
+
98
+ register :flag, name: :force, aliases: ['-f'], parent: :dep_add, type: :boolean, desc: 'force the dependency to be added even if the provided directory does not contain a pom.xml or the dependency ID is already in use'
99
+
100
+ register(:command, id: :dep_remove, parent: :dep, name: 'remove', aliases: %w(rm delete del unregister unreg), short_desc: 'remove DEP_ID', desc: 'remove a dependency from the list') { |dep_id = nil|
101
+ if dep_id.nil?
102
+ if options[:all]
103
+ resp = ''
104
+ unless options[:force]
105
+ print 'Are you sure you want to remove all registered dependencies? (y/n) '
106
+ resp = IO.console.readline.chomp
107
+ end
108
+ if options[:force] || resp.downcase == 'y' || resp.downcase == 'yes'
109
+ DataStore.deps.clear
110
+ DataStore.save
111
+ puts 'Removed all dependencies'
112
+ end
113
+ else
114
+ puts 'You must specify a dependency ID to remove or use the -A / --all flag'
115
+ end
116
+ else
117
+ if DataStore.deps.keys.include?(dep_id)
118
+ DataStore.deps.delete(dep_id)
119
+ puts "Removed dependency '#{dep_id}'"
120
+ else
121
+ puts "Dependency ID #{dep_id} does not belong to a registered dependency."
122
+ end
123
+ end
124
+ }
125
+
126
+ register :flag, name: :all, aliases: ['-A'], parent: :dep_remove, type: :boolean, desc: 'remove all registered dependencies'
127
+ register :flag, name: :force, aliases: ['-f'], parent: :dep_remove, type: :boolean, desc: 'skip confirmation of remove all'
128
+
129
+ register(:helper, name: 'args_to_hash', parent: nil) { |*args|
130
+ arg_hash = { me: [] }
131
+ exclude = []
132
+ cur_id = :me
133
+ args.each { |v|
134
+ if v.start_with?('+')
135
+ cur_id = v[1..-1]
136
+ arg_hash[cur_id] ||= []
137
+ elsif v.start_with?('~')
138
+ exclude << v[1..-1]
139
+ else
140
+ arg_hash[cur_id] << v
141
+ end
142
+ }
143
+ [arg_hash, exclude]
144
+ }
145
+
146
+ register(:helper, name: 'make_mvn2_command', parent: nil) { |mine|
147
+ "mvn2 #{array_to_args(mine).join(' ')}"
148
+ }
149
+
150
+ register(:helper, name: 'array_to_args', parent: nil) { |arr|
151
+ arr.map { |v| v.start_with?('-') ? v : "\"#{v}\"" }
152
+ }
153
+
154
+ register(:helper, name: 'make_chain_command', parent: nil) { |dep_id, arg_hash, exclude|
155
+ "mvn2chain exec #{chain_args(dep_id, arg_hash, exclude).join(' ')}"
156
+ }
157
+
158
+ register(:helper, name: 'chain_args', parent: nil) { |dep_id, arg_hash, exclude|
159
+ args = arg_hash[dep_id] || []
160
+ arg_hash.each { |v|
161
+ id = v[0]
162
+ unless id == dep_id
163
+ dep_args = v[1]
164
+ args << "+#{id}"
165
+ args += dep_args
166
+ end
167
+ }
168
+ args = array_to_args(args)
169
+ args += (exclude || []).map { |v| "~#{v}" }
170
+ }
171
+
172
+ register(:command, id: :exec, parent: nil, name: 'exec', aliases: %w(build), short_desc: 'exec [ARGS...]', desc: 'execute a mvn2 build.',
173
+ long_desc: <<LONGDESC
174
+ Execute a mvn2 build.
175
+
176
+ Specify arguments for mvn2 as you would normally, and switch to specifying arguments for a dependency (direct or indirect) with a +dep, where 'dep' is the dependency id.
177
+
178
+ To skip a dependency, include a ~dep where 'dep' is the id of the dependency to exclude.
179
+
180
+ Each dependency will be given the arguments for all other dependencies, as well as all of the excludes. This way, if you want to specify an argument for a dependency of a dependency, you can specify it the same way as for a direct dependency.
181
+ LONGDESC
182
+ ) { |*args|
183
+ arg_hash, exclude = args_to_hash(*args)
184
+ mine = arg_hash.delete(:me)
185
+ dir = Dir.getwd
186
+ unless DataStore.deps.empty?
187
+ puts "Starting in #{dir}"
188
+ DataStore.deps.each { |v|
189
+ if exclude.include?(v[0])
190
+ puts "Skipping '#{v[0]}'"
191
+ else
192
+ puts "Switching to #{v[1]}"
193
+ Dir.chdir(v[1])
194
+ chain_command = make_chain_command(v[0], arg_hash, exclude)
195
+ puts "> #{chain_command}"
196
+ system(chain_command)
197
+ end
198
+ }
199
+ puts "Switching back to #{dir}"
200
+ Dir.chdir(dir)
201
+ end
202
+ mvn2_command = make_mvn2_command(mine)
203
+ puts "> #{mvn2_command}"
204
+ system(mvn2_command)
205
+ }
206
+ end
207
+ end
208
+
209
+ root_command = Class.new(Thor)
210
+ Plugins.get :command, root_command, nil
211
+
212
+ root_command.start(ARGV)
@@ -0,0 +1,3 @@
1
+ module Mvn2chain
2
+ VERSION = '1.0.0'
3
+ end
data/lib/mvn2chain.rb ADDED
@@ -0,0 +1 @@
1
+ require 'mvn2chain/version'
data/mvn2chain.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mvn2chain/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'mvn2chain'
8
+ spec.version = Mvn2chain::VERSION
9
+ spec.authors = ['Eric Henderson']
10
+ spec.email = ['henderea@gmail.com']
11
+ spec.summary = %q{A command line tool that makes it easy to chain mvn2 calls.}
12
+ spec.description = %q{A command line tool that makes it easy to chain mvn2 calls. Register your dependencies with the "mvn2chain dep" commands and run them with the "mvn2chain exec" command. See "mvn2chain help", "mvn2chain help dep", and "mvn2chain help exec" for more information. Some commands have aliases.}
13
+ spec.homepage = 'https://github.com/henderea/mvn2chain'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 1.9.3'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+
26
+ spec.add_dependency 'everyday-cli-utils', '~> 1.7'
27
+ spec.add_dependency 'everyday-plugins', '~> 1.2'
28
+ spec.add_dependency 'everyday_thor_util', '~> 1.2'
29
+ spec.add_dependency 'thor', '~> 0.19'
30
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mvn2chain
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Henderson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: everyday-cli-utils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: everyday-plugins
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: everyday_thor_util
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.19'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.19'
97
+ description: A command line tool that makes it easy to chain mvn2 calls. Register
98
+ your dependencies with the "mvn2chain dep" commands and run them with the "mvn2chain
99
+ exec" command. See "mvn2chain help", "mvn2chain help dep", and "mvn2chain help
100
+ exec" for more information. Some commands have aliases.
101
+ email:
102
+ - henderea@gmail.com
103
+ executables:
104
+ - mvn2chain
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/mvn2chain
114
+ - lib/mvn2chain.rb
115
+ - lib/mvn2chain/version.rb
116
+ - mvn2chain.gemspec
117
+ homepage: https://github.com/henderea/mvn2chain
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 1.9.3
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.2.2
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: A command line tool that makes it easy to chain mvn2 calls.
141
+ test_files: []
142
+ has_rdoc: