-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpomfrite
executable file
·96 lines (66 loc) · 1.57 KB
/
pomfrite
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
#! /usr/bin/ruby
#
# Example:
# ./pomfrite -p loway-tpf -v 123 -j slf4j-api-1.7.5.jar -r repo
#
require 'json'
require 'pp'
require 'erb'
require 'optparse'
version = nil
project = nil
jarfile = nil
reporoot = "."
def splitref( gradlestyle )
pomref = {
"grp"=> "?",
"art"=> "?",
"ver"=> "?"
}
if ( gradlestyle =~ /^(.+?):(.+?):(.+?)$/) then
pomref["grp"] = $1
pomref["art"] = $2
pomref["ver"] = $3
end
pomref
end
#
#
#
optparse = OptionParser.new do|opts|
# Set a banner, displayed at the top
# of the help screen.
opts.banner = "Usage: optparse1.rb [options] file1 file2 ..."
# Define the options, and what they do
opts.on( '-j', '--jarfile F', '...' ) do |f|
jarfile = f
end
opts.on( '-v', '--version F', '...' ) do |f|
version = f
end
opts.on( '-p', '--project F', '...' ) do |f|
project = f
end
opts.on( '-r', '--root F', '...' ) do |f|
reporoot = f
end
end
optparse.parse!
puts "Jar: #{jarfile} Project: #{project} Version: #{version} Reporoot: #{reporoot}"
json = File.read("./recipes/#{project}.json")
cfg = JSON.parse(json)
groupdir = cfg['group'].gsub('.','/')
jarfolder = "#{reporoot}/#{groupdir}/#{cfg['artifact']}/#{version}"
artiver = "#{cfg['artifact']}-#{version}"
newjar = "#{jarfolder}/#{artiver}.jar"
newpom = "#{jarfolder}/#{artiver}.pom"
#pp cfg
puts "Copy to: #{newjar} in #{jarfolder}"
# create folder
%x[ mkdir -p #{jarfolder} ]
%x[ cp #{jarfile} #{newjar} ]
template = File.new("./pom_sample.erb").read
renderer = ERB.new(template)
File.open( newpom, 'w') { |file|
file.write(renderer.result())
}