-
Notifications
You must be signed in to change notification settings - Fork 10
/
product.rb
executable file
·94 lines (78 loc) · 2.88 KB
/
product.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
#!/usr/bin/env ruby
# Copyright (c) 2013 to Jason van Zyl
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
require 'mustache'
require 'rexml/document'
require 'yaml'
include REXML
featureDefs = YAML.load_file('product.yml')
repositories = []
features = []
featureSets = []
featureDefs['repos'].each do |repo|
repositories << repo
end
featureDefs['featureSets'].each do |featureSetHolder|
featureSetHolder.each do |id,featureSet|
unless featureSet['repo'].nil?
repository = { 'id' => id, 'url' => featureSet['repo'] }
repositories << repository
end
featureSets << featureSet
featureSet['features'].each do |feature|
features << feature
end
end
end
pluginId = "io.tesla.ide"
featureDirectory = pluginId + ".feature"
productDirectory = pluginId + ".rcp"
# Create vars to inject into the mustache template rendering process
# TODO: these should all be captured in the product file
vars = {}
vars[:launcherName] = "TeslaIDE"
vars[:groupId] = "io.tesla.ide"
vars[:mavenVersion] = "1.0.0-SNAPSHOT"
vars[:tychoVersion] = "0.19.0"
vars[:version] = "1.0.0.qualifier"
vars[:pluginId] = pluginId
vars[:featureId] = featureDirectory
vars[:productDirectory] = productDirectory
vars[:productId] = featureDefs['productId']
vars[:repositories] = repositories
vars[:features] = features
featureDefs['platforms'].each do |platform|
vars[platform] = platform
end
# Plugin
template = File.open('templates/plugin.mustache').read
plugin = Mustache.render(template, vars)
File.open(pluginId + "/plugin.xml", 'w') { |f|
f.write(plugin)
}
# Feature
template = File.open('templates/feature.mustache').read
feature = Mustache.render(template, vars)
File.open(featureDirectory + "/feature.xml", 'w') { |f|
f.write(feature)
}
# Product
template = File.open('templates/product.mustache').read
product = Mustache.render(template, vars)
File.open("io.tesla.ide.rcp/io.tesla.ide.rcp.product", 'w') { |f|
f.write(product)
}
# Poms
pomTemplate = File.open('templates/pom.parent.mustache').read
parentPom = Mustache.render(pomTemplate, vars)
File.open("pom.xml", 'w') { |f|
f.write(parentPom)
}
pomTemplate = File.open('templates/pom.product.mustache').read
productPom = Mustache.render(pomTemplate, vars)
File.open(productDirectory + "/pom.xml", 'w') { |f|
f.write(productPom)
}