forked from obiba/opal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
331 lines (276 loc) · 8.42 KB
/
Makefile
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
##
## Makefile for Opal developers
##
version=4.5-SNAPSHOT
magma_version=3.0-SNAPSHOT
commons_version=2.1-SNAPSHOT
java_opts="-Xms1G -Xmx4G -XX:MaxPermSize=256M -XX:+UseG1GC"
#java_opts="-Xms1G -Xmx4G -XX:MaxPermSize=256M"
projects=$(CURDIR)/..
opal_project=$(CURDIR)
magma_project=${projects}/magma
commons_project=${projects}/obiba-commons
ds4j_project=${projects}/datashield4j
jennite_project=${projects}/jennite
obiba_home=${projects}/obiba-home
ifdef OPAL_HOME
opal_home = ${OPAL_HOME}
else
opal_home = ${opal_project}/opal_home
endif
skipTests=false
mvn_exec=mvn -Dmaven.test.skip=${skipTests}
orientdb_version=2.2.37
hsqldb_version=2.3.3
mysql_root=root
mysql_password=1234
opal_db=opal_dev
key_db=key_dev
#
# Compile Opal and prepare Opal server
#
all: clean compile server
#
# Clean Opal
#
clean:
cd ${opal_project} && \
${mvn_exec} clean
#
# Compile Opal
#
compile:
cd ${opal_project} && \
${mvn_exec} -U install
#
# Compile Opal without compiling GWT
#
compile-no-gwt:
cd ${opal_project} && \
${mvn_exec} install -Dgwt.compiler.skip=true
#
# Update Opal source code
#
update:
cd ${opal_project} && \
git pull
#
# Unzip Opal distribution
#
server:
cd ${opal_project}/opal-server/target && \
unzip opal-server-${version}-dist.zip
#
# Launch Opal
#
run:
export OPAL_HOME=${opal_home} && \
export JAVA_OPTS=${java_opts} && \
sed -i 's/^java $$JAVA_OPTS $$JAVA_DEBUG/java $$JAVA_OPTS/g' ${opal_project}/opal-server/target/opal-server-${version}/bin/opal && \
${opal_project}/opal-server/target/opal-server-${version}/bin/opal
#
# Launch Opal in debug mode
#
debug:
export OPAL_HOME=${opal_home} && \
export JAVA_OPTS=${java_opts} && \
sed -i 's/^java $$JAVA_OPTS $$JAVA_DEBUG/java $$JAVA_OPTS/g' ${opal_project}/opal-server/target/opal-server-${version}/bin/opal && \
sed -i 's/^java $$JAVA_OPTS/java $$JAVA_OPTS $$JAVA_DEBUG/g' ${opal_project}/opal-server/target/opal-server-${version}/bin/opal && \
${opal_project}/opal-server/target/opal-server-${version}/bin/opal
#
# Launch Opal GWT
#
launch-gwt:
cd ${opal_project}/opal-gwt-client && \
${mvn_exec} gwt:run
#
# Launch Opal GWT in debug mode (port 8001)
#
launch-gwt-debug:
cd ${opal_project}/opal-gwt-client && \
${mvn_exec} gwt:debug -Dgwt.debugPort=8001
#
# Launch Rserve daemon
#
launch-Rserve:
R CMD Rserve --vanilla
#
# Execute a R script
#
launch-R:
R --vanilla < ${R}
#
# Compile and install a Opal Python Client
#
python:
cd ${opal_project}/../opal-python-client && \
${mvn_exec} clean install
#
# Execute Python client
#
launch-python:
cd ${opal_project}/../opal-python-client/target/opal-python/bin && \
chmod +x ./scripts/opal && \
export PYTHONPATH=${opal_project}/../opal-python-client/target/opal-python/bin && \
./scripts/opal ${args}
#
# Prepare opal home
#
prepare: conf fs
conf:
mkdir -p ${opal_home} && \
cp -r ${opal_project}/opal-server/src/main/conf ${opal_home}
fs:
mkdir -p ${opal_home} && \
cp -r ${obiba_home}/opal/seed/fs ${opal_home}
#
# Compile and install a Opal sub-project
#
opal:
cd ${opal_project}/${p} && \
${mvn_exec} clean install && \
cp target/${p}-${version}.jar ${opal_project}/opal-server/target/opal-server-${version}/lib
#
# Update Magma source code
#
magma-update:
cd ${magma_project} && \
git pull
#
# Compile and install a Magma sub-project
#
magma:
cd ${magma_project}/${p} && \
${mvn_exec} clean install && \
cp target/${p}-${magma_version}.jar ${opal_project}/opal-server/target/opal-server-${version}/lib
#
# Compile and install all Magma sub-projects
#
magma-all:
cd ${magma_project} && \
${mvn_exec} clean install && \
find ${opal_project}/opal-server/target/opal-server-${version}/lib -type f | grep magma | xargs rm && \
cp `find . -type f | grep jar$$ | grep -v sources | grep -v javadoc | grep -v jacoco | grep -v magma-filter | grep -v magma-beans | grep -v magma-data-generator | grep -v magma-spring | grep -v magma-test | grep -v magma-integration` ${opal_project}/opal-server/target/opal-server-${version}/lib
#
# Compile and install a Commons sub-project
#
commons:
cd ${commons_project}/${p} && \
${mvn_exec} clean install && \
cp target/${p}-${commons_version}.jar ${opal_project}/opal-server/target/opal-server-${version}/lib
#
# Compile and install all Commons sub-projects
#
commons-all:
cd ${commons_project} && \
${mvn_exec} clean install && \
find ${opal_project}/opal-server/target/opal-server-${version}/lib -type f | grep obiba- | xargs rm && \
cp `find . -type f | grep jar$$ | grep -v sources | grep -v javadoc` ${opal_project}/opal-server/target/opal-server-${version}/lib && \
rm ${opal_project}/opal-server/target/opal-server-${version}/lib/obiba-*-cli.jar && \
rm ${opal_project}/opal-server/target/opal-server-${version}/lib/obiba-jersey-*.jar && \
rm ${opal_project}/opal-server/target/opal-server-${version}/lib/obiba-mongodb-*.jar
#
# Compile and install all DataSHIELD4J sub-projects
#
ds4j-all:
cd ${ds4j_project} && \
${mvn_exec} clean install && \
find ${opal_project}/opal-server/target/opal-server-${version}/lib -type f | grep ds4j | xargs rm && \
cp `find . -type f | grep jar$$ | grep -v sources | grep -v javadoc` ${opal_project}/opal-server/target/opal-server-${version}/lib
#
# Compile and install jennite
#
jennite:
cd ${jennite_project} && \
${mvn_exec} clean install && \
cp ${jennite_project}/jennite-vcf-store/target/*-dist.zip ${opal_home}/plugins/
#
# Tail Opal log file
#
log:
tail -f ${opal_home}/logs/opal.log
#
# Delete all log files
#
clear-log:
rm ${opal_home}/logs/*
#
# Delete ES indexes
#
clear-data:
rm -rf ${opal_home}/data/opal/*
clear-config:
rm -rf ${opal_home}/data && \
rm -rf ${opal_home}/conf && \
rm -rf ${opal_home}/logs && \
rm -rf ${opal_home}/work
check-updates:
cd ${opal_project} && ${mvn_exec} versions:display-dependency-updates
check-plugin-updates:
cd ${opal_project} && ${mvn_exec} versions:display-plugin-updates
check-magma-updates:
cd ${magma_project} && ${mvn_exec} versions:display-dependency-updates
#
# Dump MySQL databases
#
sql-dump: sql-opal-dump sql-key-dump
sql-opal-dump:
mysqldump -u $(mysql_root) --password=$(mysql_password) --hex-blob --max_allowed_packet=1G $(opal_db) > $(opal_db)_$(version)_dump.sql
sql-key-dump:
mysqldump -u $(mysql_root) --password=$(mysql_password) $(key_db) > $(key_db)_$(version)_dump.sql
#
# Drop databases and import SQL dump
#
sql-import: sql-opal-import sql-key-import
sql-opal-import:
mysql -u $(mysql_root) --password=$(mysql_password) -e "drop database `$(opal_db)`; create database `$(opal_db)`;" && \
mysql -u $(mysql_root) --password=$(mysql_password) `$(opal_db)` < $(opal_db)_$(version)_dump.sql
sql-key-import:
mysql -u $(mysql_root) --password=$(mysql_password) -e "drop database `$(key_db)`; create database `$(key_db)`;" && \
mysql -u $(mysql_root) --password=$(mysql_password) `$(key_db)` < $(key_db)_$(version)_dump.sql
download-orientdb:
mkdir -p ${opal_home}/work && \
cd ${opal_home}/work && \
wget "https://s3.us-east-2.amazonaws.com/orientdb3/releases/$(orientdb_version)/orientdb-community-importers-$(orientdb_version).zip" && \
unzip orientdb-community-importers-$(orientdb_version).zip && \
rm orientdb-community-importers-$(orientdb_version).zip && \
chmod a+x orientdb-community-importers-$(orientdb_version)/bin/*.sh
orientdb-console:
@echo
@echo "To connect to Opal OrientDB:"
@echo " connect premote:localhost:2424/opal-config admin admin"
@echo "or"
@echo " connect plocal:$(opal_home)/data/orientdb/opal-config admin admin"
@echo
@cd ${opal_home}/work/orientdb-community-importers-$(orientdb_version)/bin && ./console.sh
hsqldb-tool:
cd ${opal_home} && \
java -jar ../opal-server/target/opal-server-$(version)/lib/hsqldb-$(hsqldb_version).jar --url jdbc:hsqldb:file:data/hsql/opal_config --user opal --password $(hsqldb_pwd)
#
# GWT locales
#
locales:
cd ${opal_project}/opal-gwt-client && \
${mvn_exec} antrun:run
#
# Plugins
#
plugins: search-plugin datasource-plugins analysis-plugins
vcf-plugin: jennite
search-plugin:
$(call install-plugin,opal-search-es)
datasource-plugins:
$(call install-plugin,opal-datasource-spss)
$(call install-plugin,opal-datasource-limesurvey)
$(call install-plugin,opal-datasource-redcap)
$(call install-plugin,opal-datasource-googlesheets4)
$(call install-plugin,opal-datasource-readr)
$(call install-plugin,opal-datasource-readxl)
analysis-plugins:
$(call install-plugin,opal-analysis-validate)
plugin:
$(call install-plugin,${p})
#
# Functions
#
install-plugin = cd ${projects}/$(1) && mvn clean install && cp target/$(1)-*-dist.zip ${opal_home}/plugins/