-
Notifications
You must be signed in to change notification settings - Fork 0
/
mvn.rb
125 lines (105 loc) · 2.64 KB
/
mvn.rb
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/ruby
# Launchy Config <runner plugin>:
# mvn
# C:\Windows\System32\cmd.exe
# /K "ruby C:\java\ProgrammerTools\bin\ruby\mvn.rb $$"
# Launchy Command: mvn <tab> <project name>...
require 'fileutils'
require 'yaml'
require 'javascript_hash'
@config = nil
@mvnCommand = ""
def prettyArray(arg)
ret = " "
array = arg.sort
array.each{|key, value|
if (value)
ret += key + " "
end
}
ret
end
def pretty_maven_arguments()
ret = ""
@config.maven.arguments.each{ |it|
ret += it + " "
}
ret
end
def addBuild(dir, mavenArgs, flags)
projectDirectory = String.new(@config.directory)
projectDirectory = File.join(projectDirectory.gsub("\\", "/"), dir)
if(@mvnCommand.length > 0)
@mvnCommand << " && "
end
@mvnCommand << "mvn #{prettyArray(mavenArgs)} -f #{projectDirectory}/pom.xml #{pretty_maven_arguments()} "
end
def setToForIn(status, args, map)
argsArray = args.split(//)
argsArray.each { |char|
map.each { |key, value|
regex = Regexp.new("^"+char+".+")
if(regex.match(key))
map[key] = status
end
}
}
end
# m ci ip ci gw p i =>
# mvn clean install isl-privateloan
# mvn clean install genesis/genesis-web
# mvn process-sources integration
def process(args, flags, mavenArgs, dirMappings)
doMavenArgs = true;
args.each do |arg|
if(/^-/.match(arg))
next
end
if(doMavenArgs)
setToForIn(false, "cipt", mavenArgs)
setToForIn(true, arg, mavenArgs)
else
dirMappings.each{ |it|
puts dirMappings[it]
puts it
}
if(dirMappings[arg])
addBuild(dirMappings[arg], mavenArgs, flags)
else
regexStr = "^"
arg.gsub(/./){|s| regexStr += s+"[a-zA-Z]*-"}
regexStr = regexStr.chop
regexStr += "$"
regex = Regexp.new(regexStr)
dirEntries = Dir.entries(@config.directory)
dirEntries.each{|x|
if (regex.match(x))
addBuild(x, mavenArgs, flags)
break
end
}
end
end
doMavenArgs = !doMavenArgs
end
puts "****************************************************"
puts "Maven Command(s) to execute:\n" + @mvnCommand.gsub(" && ", " &&\n")
puts "****************************************************\n\n"
system (@mvnCommand)
end
def parsePhases()
s = @config.maven.phases
phases = { }
s.each{|it|
phases[it] = false
}
phases
end
file_location = ENV['M_SETTINGS_FILE']
if(file_location == nil)
file_location = "mvnSettings.yml"
end
@config = YAML::load_file(file_location);
flags={}
flags[:printDoNotRun]=ARGV.include?("-v")
process(ARGV, flags, parsePhases(), @config.mappings )