forked from sgithens/OAE-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bld.rake
130 lines (117 loc) · 3.88 KB
/
bld.rake
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
126
127
128
129
130
namespace :bld do
desc "Clone the repositories needed to build everything"
task :clone do
cmds = []
if @ui.has_key? "path"
if File.directory? @ui["path"]
@logger.info "#{@ui["path"]} already exists."
elsif @ui.has_key? "repository"
@logger.info "Cloning #{@ui["repository"]} to #{@ui["path"]}"
Git.clone(@ui["repository"], @ui["path"])
if @ui.has_key? "remote" and @ui["remote"] != "origin"
cmds << "(cd #{@ui["path"]} && git remote rename origin #{@ui["remote"]})"
end
end
end
@server.each do |p|
if p.has_key? "path"
if File.directory? p["path"]
@logger.info "#{p["path"]} already exists."
elsif p.has_key? "repository"
@logger.info "Cloning #{p["repository"]} to #{p["path"]}"
Git.clone(p["repository"], p["path"])
if p.has_key? "remote" and p["remote"] != "origin"
cmds << "(cd #{p["path"]} && git remote rename origin #{p["remote"]})"
end
end
end
end
if !cmds.empty?
@logger.info "\nPlease issue the following commands:"
cmds.each do |cmd|
@logger.info cmd
end
@logger.info ""
end
end
desc "Clean files and directories from a previous server start"
task :clean => ['ctl:kill', 'bld:clean:mysql'] do
touch CLEAN_FILES
rm_r CLEAN_FILES
end
desc "Update (git pull) all Nakamura and UI projects (alias: up)"
task :update do
if @update_ui then
g = Git.open(@ui["path"])
remote = @ui["remote"] || "origin"
branch = remote + "/" + (@ui["branch"] || "master")
localbranch = @ui["localbranch"] || "master"
@logger.info "Checkout out #{localbranch}"
g.checkout(g.branch(localbranch))
@logger.info "Updating #{@ui["path"]}:#{branch}"
@logger.info g.pull(remote, branch)
end
@server.each do |p|
g = Git.open(p["path"])
remote = p["remote"] || "origin"
branch = remote + "/" + (p["branch"] || "master")
localbranch = p["localbranch"] || "master"
@logger.info "Checkout out #{localbranch}"
g.checkout(g.branch(localbranch))
@logger.info "Updating #{p["path"]}:#{branch}"
@logger.info g.pull(remote, branch)
end
end
task :up => 'bld:update'
desc "Rebuild the UI and Nakamura projects"
task :rebuild => ['conf:config'] do
Dir.chdir @ui["path"] do
system("#{@mvn_cmd} clean install")
end
@server.each do |p|
Dir.chdir p["path"] do
system("#{@mvn_cmd} clean install")
end
end
end
desc "Rebuild just the app bundle to include any changed bundles without building everything"
task :fastrebuild => ['conf:config'] do
Dir.chdir "#{@builddir}/nakamura/app" do
system("#{@mvn_cmd} clean install")
end
end
desc "Create a release build of the UI, regular build of everything else, and run it"
task :release => ['ctl:clean', 'bld:update', 'bld:release:build', 'ctl:run'] do
end
desc "Update and rebuild the UI and Nakamura projects"
task :build => ['bld:update', 'bld:rebuild']
namespace :clean do
desc "Clean the mysql db"
task :mysql do
if @db["driver"] == "mysql"
my = Mysql::new("localhost", @db["user"], @db["password"])
my.query("drop database if exists #{@db["db"]}")
my.query("create database #{@db["db"]} default character set 'utf8'")
end
end
desc "Clean the build artifacts generated by the UI build"
task :ui do
Dir.chdir @ui["path"] do
system("#{@mvn_cmd} clean")
end
end
end
namespace :release do
desc "Rebuild the UI and Nakamura projects, using a release build for the UI"
task :build do
Dir.chdir @ui["path"] do
system("#{@mvn_cmd} clean install -P sakai-release")
end
@server.each do |p|
Dir.chdir p["path"] do
system("#{@mvn_cmd} clean install")
end
end
end
end
end