forked from sgithens/OAE-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
172 lines (136 loc) · 5.1 KB
/
Rakefile
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
require 'net/http'
require 'uri'
require 'fileutils'
require 'socket'
require 'rexml/document'
require 'rexml/xpath'
require 'zlib'
require 'archive/tar/minitar'
require 'logger'
include SlingInterface
# Our own little logger, because the default one is ugly
class SakaiLogger < Logger::Formatter
def call(severity, time, program_name, message)
datetime = time.strftime("%Y-%m-%d %H:%M")
"[#{datetime}] #{severity}: #{String(message)}\n"
end
end
# before settings is created
logger = Logger.new STDOUT
logger.formatter = SakaiLogger.new
logger.level = Logger::DEBUG
# KERN-2260
if RUBY_VERSION =~ /^1\.8/
class Dir
class << self
def exists? (path)
File.directory?(path)
end
alias_method :exist?, :exists?
end
end
end
# Make sure we always start from where the Rakefile is
Dir.chdir(File.dirname(__FILE__))
@oaebuilder_dir = File.expand_path('.')
@builddir = ENV['builddir']
unless @builddir then
@builddir = ".."
end
#sparse = {"path" => "#{@builddir}/sparsemapcontent", "repository" => "git://github.com/sakaiproject/sparsemapcontent.git", "branch" => "master", "localbranch" => "master"}
#solr = {"path" => "#{@builddir}/solr", "repository" => "git://github.com/sakaiproject/solr.git", "branch" => "master", "localbranch" => "master"}
nakamura = {"path" => "#{@builddir}/nakamura", "repository" => "git://github.com/sakaiproject/nakamura.git", "branch" => "master", "localbranch" => "master", "port" => "8080"}
ui = {"path" => "#{@builddir}/3akai-ux", "repository" => "git://github.com/sakaiproject/3akai-ux.git", "branch" => "master", "localbranch" => "master"}
fsresources = ["/dev", "/devwidgets", "/tests"]
cle = {"path" => "#{@builddir}/sakai-cle", "repository" => "https://source.sakaiproject.org/svn/sakai/branches/sakai-2.8.1", "port" => "8880", "ajp_port" => "8889" }
hybrid = {"path" => "#{cle["path"]}/hybrid", "repository" => "https://source.sakaiproject.org/svn/hybrid/branches/hybrid-1.1.x"}
db = {"driver" => "derby", "user" => "sakaiuser", "password" => "ironchef", "db" => "nakamura"}
tomcat = {"mirror" => "archive.apache.org", "prefix" => "dist", "version" => "5.5.34"}
hostname = Socket.gethostname
templatePath = "./templates"
num_users_groups = 5
update_ui = true
Mustache.template_path = "./templates"
# setup java command and options
java_exec = "java"
java_opts = "-Dfile.encoding=UTF8 -Xms256m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=512m"
java_debug_opts = "-Xdebug -Xrunjdwp:transport=dt_socket,address=8500,server=y,suspend=n"
java_debug = false
app_opts = ""
# Custom app jar file pattern
app_file = "#{nakamura["path"]}/app/target/org.sakaiproject.nakamura.app-*.jar"
# setup maven command and options
mvn_exec = "mvn"
mvn_opts = "-B -e -Dmaven.test.skip"
# read in and evaluate an external settings file
eval File.open('./settings.rb').read if File.exists?('./settings.rb')
server = [nakamura] if server.nil?
@mvn_cmd = "#{mvn_exec} #{mvn_opts}"
@java_cmd = "#{java_exec} #{java_opts}"
if java_debug
@java_cmd += " #{java_debug_opts}"
end
if db["driver"] == "mysql"
Bundler.require(:mysql)
end
CLEAN_FILES = ["./derby.log", "./sling", "./activemq-data", "./store", "./sakai2-demo", "./tmp", "./ui-conf"]
## copy some vars to a higher scope for commands defined in separate rake files
## we do it this way so changes in settings.rb are local vars and you don't have
## to keep track of the scope of the settings.
@nakamura = nakamura
@server = server
@ui = ui
@fsresources = fsresources
@cle = cle
@hybrid = hybrid
@db = db
@tomcat = tomcat
@hybrid = hybrid
@hostname = hostname
@templatePath = templatePath
@num_users_groups = num_users_groups
@update_ui = update_ui
@app_file = app_file
@app_opts = app_opts
@logger = logger
@sling = Sling.new("http://localhost:#{@nakamura["port"]}")
## log some initial values before reading in other task definitions
@logger.info "Using settings:"
@logger.info " JAVA: #{@java_cmd}"
@logger.info " MVN: #{@mvn_cmd}"
@logger.info " UI: #{ui.inspect}"
@logger.info " SERVER: #{server.inspect}"
# include external rake file for custom tasks
Dir.glob('*.rake').each { |r| import r }
# Fix header setting for Net::HTTP
module Net::HTTPHeader
def initialize_http_header(initheader)
@header = { "Referer" => ["http://localhost:8080"] }
return unless initheader
initheader.each do |key, value|
warn "net/http: warning: duplicated HTTP header: #{key}" if key?(key) and $VERBOSE
@header[key.downcase] = [value.strip]
end
end
end
########################
## Task Definitions ##
########################
desc 'Create users, greate groups, make connections, send messages, set FSResource, clean the UI'
task :setup => ['data:setup', 'conf:fsresource:set', 'bld:clean:ui']
desc 'Clean, build and run'
task :default => ['bld:clean', 'bld:build', 'ctl:run']
## alias common tasks
desc 'Shortcut to ctl:run'
task :run => 'ctl:run'
desc 'Shortcut to ctl:stop'
task :kill => 'ctl:stop'
desc 'Shortcut to ctl:stat'
task :stat => 'ctl:stat'
desc 'Shortcut to bld:update'
task :update => 'bld:update'
desc 'Shortcut to bld:clean'
task :clean => 'bld:clean'