This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
191 lines (166 loc) · 4.61 KB
/
build.gradle
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
apply plugin: 'distribution'
project.ext {
environment = [PATH: '/bin/:/usr/bin/:/usr/local/bin/']
}
def make(String target) {
println "make: ${target}"
exec {
commandLine 'bash', '-c', 'source ./vars && make ' + target
}
}
def sudo_make(String target) {
println "sudo make: ${target}"
exec {
commandLine 'bash', '-c', 'source ./vars && sudo make ' + target
}
}
task checkDependencies {
doLast {
def out = new ByteArrayOutputStream()
exec {
commandLine 'php', '--version'
standardOutput out
}
println out.toString().readLines()[0]
def php_installed = false
out.toString().find(/PHP (\d+).(\d+)/) { match, major, minor ->
if (major > 5 || major == 5 && minor >= 4) {
println "Found PHP version ${major}.${minor}."
php_installed = true
}
}
if (!php_installed) {
throw new StopActionException('PHP version >= 5.4 required.')
}
out.reset()
exec {
commandLine 'svn', '--version'
standardOutput out
}
println out.toString().readLines()[0]
}
}
task createVars(type: Exec) {
commandLine 'make', '-C', 'env', '../vars'
}
createVars.onlyIf { !file('vars').exists() }
createVars.dependsOn 'checkDependencies'
def etl_target = 'env/tranSMART-ETL'
task downloadTransmartETL {
doLast {
def repo = 'https://github.com/transmart/tranSMART-ETL/trunk'
exec {
commandLine 'svn', 'checkout', '--depth', 'immediates', repo, etl_target
}
exec {
commandLine 'svn', 'up', '--set-depth=infinity', "${etl_target}/Postgres"
}
exec {
commandLine 'svn', 'up', '--set-depth=infinity', "${etl_target}/Kettle-GPL"
}
}
}
downloadTransmartETL.onlyIf { !file(etl_target).exists() }
downloadTransmartETL.dependsOn 'checkDependencies'
task downloadR {
doLast {
make('-C R sources')
}
}
downloadR.dependsOn 'createVars'
distTar.dependsOn 'downloadR'
task generateRequiredFiles {
doLast {
make('-C ddl/postgres extension_sources')
make('-C ddl/postgres drivers')
make('-C ddl/oracle drivers')
make('-C data/common makefiles')
make('-C ddl/postgres/META default_permissions.tsv')
make('-C data/common/searchapp/plugin_modules_params ../plugin_module.tsv')
}
}
distTar.dependsOn 'generateRequiredFiles'
task setupPostgres {
doLast {
sudo_make('-C env /var/lib/postgresql/tablespaces')
make('postgres')
}
}
task copyTransmartCopy(type: Copy) {
from '../transmart-copy/build/libs'
include '*.jar'
into 'test_studies'
}
copyTransmartCopy.dependsOn ':transmart-copy:shadowJar'
task setupPostgresTest {
doLast {
sudo_make('-C env /var/lib/postgresql/tablespaces')
make('postgres_test')
}
}
setupPostgresTest.dependsOn 'createVersionFile'
setupPostgresTest.dependsOn 'copyTransmartCopy'
task setupOracle {
doLast {
make('oracle')
}
}
task setupSolr {
doLast {
make('-C solr solr_home')
}
}
setupSolr.dependsOn 'createVars'
task startSolr {
doLast {
make('-C solr start')
}
}
startSolr.dependsOn 'setupSolr'
task dataloadingTest {
doLast {
make('-C env data-integration')
make('-C samples/postgres load_clinical_GSE8581')
make('-C samples/postgres showdblog')
}
}
dataloadingTest.dependsOn 'checkDependencies'
// from https://medium.com/@ungesehn/use-gitignore-for-gradle-task-excludes-e5d011e99f71
def gitignoreToList(File f) {
def ignores = []
f.eachLine { line ->
//ignore comments and empty lines
if (!line.startsWith('#') && !line.isEmpty()) {
ignores.add(line)
}
}
return ignores
}
distributions {
main {
contents {
exclude 'lib/schemaSpy_*.jar', 'solr/solr-*/**'
from '.'
include 'config/**', 'data/**', 'ddl/**','env/**', 'lib/**', 'R/**', 'samples/**', 'solr/**',
'test_data/**', 'test_studies/**', 'updatedb/**',
'LICENSE', 'Makefile', 'makefile.inc', 'README.md', 'vars.sample', 'VERSION'
}
}
}
distZip.enabled = false
task createVersionFile {
doLast {
def file = new File("$projectDir/VERSION")
file.createNewFile()
file.text = "${version}"
}
}
distTar.dependsOn 'createVersionFile'
defaultTasks 'createVars'
publishing {
publications {
maven(MavenPublication) {
artifact distTar // Publish the output of the distTar task
}
}
}