-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaven
executable file
·77 lines (55 loc) · 2.01 KB
/
maven
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env ruby
# Documentation
# http://www.mkyong.com/maven/how-to-display-maven-plugin-goals-and-parameters/
# http://ruby-doc.org/stdlib-1.9.3/libdoc/optparse/rdoc/OptionParser.html
require 'optparse'
def run_in_shell(cmd)
IO.popen(cmd) { |io| while line = io.gets do puts line end }
end
def maven(params, exit_after_run=true)
cmd = "#{`which mvn`.strip} #{params}"
puts
puts "==================================================================================================="
puts " >> #{cmd}"
puts "==================================================================================================="
puts
puts
run_in_shell cmd
exit if exit_after_run
end
def parse_commands(opts)
if ARGV[0] == "run"
maven "jetty:run"
elsif ARGV[0] == "run-deployment"
maven "jetty:run -Dwicket.configuration=deployment"
elsif ARGV[0] == "help"
opts.abort "[ERROR] The 'help' command needs a parameter (e.g. '#{opts.program_name} help jetty' or '#{opts.program_name} help jetty:run')" if ARGV[1].nil?
if ARGV[1].include? ":"
(plugin, goal) = ARGV[1].split ":"
params = "#{plugin} -Dmojo=#{goal} -Dfull=true"
else
params = ARGV[1]
end
maven "help:describe -Dplugin=#{params}"
end
end
OPTIONS = {
:skip_tests => { :enabled => true, :param => "-Dmaven.test.skip=true" },
:skip_javadoc => { :enabled => true, :param => "-Dmaven.javadoc.skip=true" }
}
# exits if a correct command was specified
parse_commands(OptionParser.new do |opts|
opts.banner = "Usage: #{__FILE__} [options]"
opts.abort "[ERROR] Current directory is not a maven project (no pom.xml found)" unless File.exists? "pom.xml"
opts.on "-t", "--tests", "Run tests" do |t|
OPTIONS[:skip_tests][:enabled] = false
end
opts.on "-j", "--javadoc", "Generate javadoc" do |j|
OPTIONS[:skip_javadoc][:enabled] = false
end
end.parse!)
maven_options = []
for x, option in OPTIONS.reject { |k,v| not v[:enabled] }
maven_options << option[:param]
end
maven "clean install #{maven_options.join(' ')}"