This repository has been archived by the owner on Feb 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
166 lines (141 loc) · 3.81 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
SDK_LOCATIONS = [
ENV["HOME"] + '/.linuxbrew/Cellar/android-sdk/24.3.3',
'/Applications/adt-bundle/sdk',
] + Dir['/usr/local/Cellar/android-sdk/*/']
def find_java_home
SDK_LOCATIONS.find{|f| File.exists? f }
end
desc 'Set production credentials'
task :production do
ENV['BUILD_ENV'] = 'production'
end
desc 'Set development credentials'
task :development do
ENV['BUILD_ENV'] = 'development'
end
namespace :build do
desc 'Ratched Style Android'
task :prepare_android do
sh "
sed -i -E 's/ratchet\-theme\-ios\.min\.css/ratchet-theme-android\.min\.css/' ebapp/source/css/all.css
"
end
desc 'Ratched Style iOS'
task :prepare_ios do
sh "
sed -i -E 's/ratchet\-theme\-android\.min\.css/ratchet\-theme\-ios\.min\.css/' ebapp/source/css/all.css
"
end
desc 'Start Middleman auf Port 3500'
task :server => [:clear] do
sh '
cd ebapp/source && bundle exec middleman server -p 3500
'
end
desc 'Middleman build'
task :development => ['android:set_env'] do
sh '
cd ./ebapp
bundle exec middleman build
'
end
desc 'Middleman production'
task :production => ['android:set_production', :development]
desc "TMP Files loeschen"
task :clear do
rm_rf './ebapp/.cache'
rm_rf './www/'
end
end
namespace :debug do
desc 'Logcat aufs Primaere Android Device'
task :logcat do
sh '
adb logcat CordovaLog:D chromium:D *:S
'
end
desc 'Start Weinre auf Port 8080'
task :weinre do
sh 'weinre --boundHost 0.0.0.0'
end
desc 'Server auf port 3500'
task :server do
sh 'cd ebapp && bundle exec middleman server -p 3500'
end
end
namespace :android do
task :prepare =>[:set_env, 'build:prepare_android', 'build:development']
task :build => [:prepare] do
sh ' cordova build android '
end
task :set_production do
ENV['BUILD_ENV'] = 'production'
ENV['BUILD_VERSION'] = File.read('config.xml')[/version="([^"]+)"/, 1]
mkdir_p 'releases'
end
desc 'Bauen + Auf angeschlossenem Device starten'
task :usb => [:build] do
sh ' cordova run android '
end
desc 'Bauen + Emulator starten'
task :emulator => [:build] do
sh 'cordova run --emulator android '
end
desc "Regenerate Icons"
task :icons do
mkdir_p 'platforms/android/res/drawable'
mkdir_p 'platforms/android/res/drawable-xxhdpi'
sh 'cordova-icon'
end
desc 'Release einer neuen Version'
task :release => [:set_production, :prepare, :icons] do
puts "====== Generating Icons ======"
sh "cordova-icon"
puts "====== Generating Splash ======"
sh "cordova-splash"
puts "====== Releasing #{ENV['BUILD_VERSION']} ====== "
sh "cordova build android --release "
puts "===== Build Complete: Archiving ===== "
sh "mv platforms/android/build/outputs/apk/android-release.apk releases/empfehlungsbund-#{ENV['BUILD_VERSION']}.apk "
end
task :set_env => ['build:clear'] do
sdk = find_java_home
if !sdk
raise 'Android SDK nicht gefunden, habe gesucht in: ' + SDK_LOCATIONS.join("\n")
else
puts "Android SDK found in #{sdk}"
end
require 'pry'
ENV['ANDROID_HOME'] = sdk
ENV['PATH'] = ENV['PATH'] + ":#{ENV['ANDROID_HOME']}/tools:#{ENV['ANDROID_HOME']}/platform-tools"
end
end
namespace :install do
desc 'install all dependencies besides the ones from install:app'
task :brew do
sh '
brew install java
brew install ant
brew install android-sdk
brew install node
npm install -g cordova bower
npm install -g cordova-icon
npm install -g cordova-splash
'
end
desc 'install middleman + bower abh.'
task :app do
sh '
cd ebapp/
bundle
bower install
'
end
desc 'initialize cordova'
task :cordova do
sh '
cordova platform add android
android update project -p platforms/android
'
end
end