forked from realm/realm-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
448 lines (393 loc) · 14.2 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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'ch.netzwerg:gradle-release-plugin:1.2.0'
}
}
apply plugin: 'ch.netzwerg.release'
def currentVersion = file("${projectDir}/version.txt").text.trim();
def props = new Properties()
props.load(new FileInputStream("${rootDir}/realm.properties"))
props.each { key, val ->
project.ext.set(key, val)
}
task assembleAnnotations(type:GradleBuild) {
group = 'Build'
description = 'Assemble the Realm annotations'
buildFile = file('realm-annotations/build.gradle')
tasks = ['assemble']
}
task installAnnotations(type:GradleBuild) {
group = 'Install'
description = 'Install the jar realm-annotations into mavenLocal()'
buildFile = file('realm-annotations/build.gradle')
tasks = ['publishToMavenLocal']
}
task assembleTransformer(type:GradleBuild) {
group = 'Build'
description = 'Assemble the Realm transformer'
dependsOn installAnnotations
buildFile = file('realm-transformer/build.gradle')
tasks = ['assemble']
}
task installTransformer(type:GradleBuild) {
group = 'Install'
description = 'Install the jar realm-transformer into mavenLocal()'
dependsOn installAnnotations
buildFile = file('realm-transformer/build.gradle')
tasks = ['publishToMavenLocal']
}
task assembleRealm(type:GradleBuild) {
group = 'Build'
description = 'Assemble the Realm project'
dependsOn installAnnotations
dependsOn installTransformer
buildFile = file('realm/build.gradle')
tasks = ['assemble', 'javadocJar', 'sourcesJar']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
if (project.hasProperty('s3cfg')) {
startParameter.projectProperties += [s3cfg: project.getProperty('s3cfg')]
}
}
task checkExamples(type:GradleBuild) {
group = 'Test'
description = 'Run the JVM tests and checks the examples'
buildFile = file('examples/build.gradle')
tasks = ['check']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task checkRealm(type:GradleBuild) {
group = 'Test'
description = 'Run the JVM tests and checks Realm project'
buildFile = file('realm/build.gradle')
tasks = ['check']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task check {
group = 'Test'
description = 'Run the JVM tests and checks in the realm and examples projects'
dependsOn checkRealm
dependsOn checkExamples
}
task connectedUnitTests(type:GradleBuild) {
group = 'Test'
description = 'Run the Android unit tests of the Realm project'
dependsOn installTransformer
buildFile = file('realm/build.gradle')
tasks = ['connectedUnitTests']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task installRealm(type:GradleBuild) {
group = 'Install'
description = 'Install the artifacts of Realm libraries into mavenLocal()'
dependsOn installTransformer
buildFile = file('realm/build.gradle')
tasks = ['publishToMavenLocal']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
if (project.hasProperty('s3cfg')) {
startParameter.projectProperties += [s3cfg: project.getProperty('s3cfg')]
}
}
task assembleGradlePlugin(type:GradleBuild) {
group = 'Build'
description = 'Assemble the Realm Gradle plugin'
dependsOn installRealm
dependsOn installTransformer
buildFile = file('gradle-plugin/build.gradle')
tasks = ['assemble']
}
task installGradlePlugin(type:GradleBuild) {
description = 'Install the Realm Gradle plugin into mavenLocal()'
group = 'Install'
dependsOn installRealm
dependsOn installTransformer
buildFile = file('gradle-plugin/build.gradle')
tasks = ['publishToMavenLocal']
}
task installRealmJava(type:Task) {
dependsOn installGradlePlugin
dependsOn installRealm
group = 'Install'
description = 'Install the Realm library and Gradle plugin into mavenLocal()'
}
task assembleExamples(type:GradleBuild) {
dependsOn installGradlePlugin
dependsOn installRealm
group = 'Build'
description = 'Assemble the Realm examples'
buildFile = file('examples/build.gradle')
tasks = ['assemble']
}
task monkeyExamples(type:GradleBuild) {
dependsOn installGradlePlugin
dependsOn installRealm
group = 'Build'
description = 'Run the monkey tests on the Realm examples'
buildFile = file('examples/build.gradle')
tasks = ['monkeyRelease']
}
task javadoc(type:GradleBuild) {
description = 'Generate the Javadoc Jar for the Realm project'
group = 'Docs'
buildFile = file('realm/build.gradle')
tasks = ['javadocJar']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task sourcesJar(type:GradleBuild) {
description = 'Generate the sources Jar for the Realm project'
group = 'Docs'
buildFile = file('realm/build.gradle')
tasks = ['sourcesJar']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task assemble {
group 'Build'
description = 'Build Realm, the Gradle plugin and the examples'
dependsOn assembleExamples
}
task distributionPackage(type:Zip) {
description = 'Generate the distribution package'
dependsOn assembleRealm
dependsOn javadoc
group = 'Artifact'
archiveName = "realm-java-${currentVersion}.zip"
destinationDir = file("${buildDir}/outputs/distribution")
from('changelog.txt')
from('LICENSE')
from('version.txt')
from('realm.properties')
from('realm/realm-library/build/libs') {
include 'realm-android-${currentVersion}-javadoc.jar'
into 'docs'
}
from('realm/realm-library/build/docs') {
include '**/*'
into 'docs'
}
from('examples') {
exclude 'local.properties'
exclude '**/.gradle'
exclude '**/build'
into 'examples'
}
}
task distributionJniUnstrippedPackage(type:Zip) {
description = 'Generate native libs package with debug symbols'
dependsOn assembleRealm
group = 'Artifact'
archiveName = "realm-java-jni-libs-unstripped-${currentVersion}.zip"
destinationDir = file("${buildDir}/outputs/distribution")
from("realm/realm-library/build/outputs/jniLibs-unstripped") {
include '**/*.so'
}
}
task cleanRealm(type:GradleBuild) {
description = 'Clean the Realm project'
group = 'Clean'
buildFile = file('realm/build.gradle')
tasks = ['clean']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
if (project.hasProperty('dontCleanJniFiles')) {
startParameter.projectProperties += [dontCleanJniFiles: project.getProperty('dontCleanJniFiles')]
}
}
task cleanGradlePlugin(type:GradleBuild) {
description = 'Clean the Realm Gradle plugin project'
group = 'Clean'
buildFile = file('gradle-plugin/build.gradle')
tasks = ['clean']
}
task cleanExamples(type:GradleBuild) {
description = 'Clean the Realm examples'
group = 'Clean'
buildFile = file('examples/build.gradle')
tasks = ['clean']
}
task cleanLocalMavenRepos(type:Delete) {
description = 'Remove any Realm artifacts from the local Maven repositories'
group = 'Clean'
delete "${System.env.HOME}/.m2/repository/io/realm"
}
task clean {
description = 'Perform all the other clean tasks'
group = 'Clean'
cleanLocalMavenRepos.dependsOn cleanRealm
cleanLocalMavenRepos.dependsOn cleanGradlePlugin
cleanLocalMavenRepos.dependsOn cleanExamples
dependsOn cleanLocalMavenRepos
}
task manualClean {
description = 'Clean build files without using clean tasks defined in sub projects'
group = 'Clean'
doLast {
// clean 'build' directories
exec {
workingDir "${rootDir}"
commandLine 'find', '.', '-type', 'd', '-name', 'build', '-print', '-exec', 'rm', '-rf', '{}', ';', '-prune'
}
// clean '.externalNativeBuild' directories
exec {
workingDir "${rootDir}"
commandLine 'find', '.', '-type', 'd', '-name', '.externalNativeBuild', '-print', '-exec', 'rm', '-rf', '{}', ';', '-prune'
}
// clean '.gradle' directories except one in the root
exec {
workingDir "${rootDir}"
commandLine 'find', '.', '-mindepth', '2', '-type', 'd', '-name', '.gradle', '-print', '-exec', 'rm', '-rf', '{}', ';', '-prune'
}
// clean ${System.env.HOME}/.m2/repository/io/realm
exec {
workingDir "${rootDir}"
commandLine 'sh', '-c', "echo \"${System.env.HOME}/.m2/repository/io/realm\" && rm -rf \"${System.env.HOME}/.m2/repository/io/realm\""
}
}
}
task uploadDistributionPackage {
group = 'Release'
description = 'Upload the distribution package to S3'
dependsOn distributionPackage
dependsOn distributionJniUnstrippedPackage
doLast {
exec {
workingDir "${buildDir}/outputs/distribution/"
commandLine 's3cmd', 'put', "realm-java-${currentVersion}.zip", 's3://static.realm.io/downloads/java/'
}
exec {
workingDir "${buildDir}/outputs/distribution/"
commandLine 's3cmd', 'put', "realm-java-jni-libs-unstripped-${currentVersion}.zip", 's3://static.realm.io/downloads/java/'
}
}
}
task createEmptyFile(type: Exec) {
group = 'Release'
description = 'Create an empty file that will serve as a link on S3'
dependsOn uploadDistributionPackage
commandLine 'touch', 'latest'
}
['java', 'android'].each() { link ->
task "upload${link.capitalize()}LatestLink"(type: Exec) {
group = 'Release'
description = "Update the link to the latest version for ${link.capitalize()}"
dependsOn createEmptyFile
commandLine 's3cmd', 'put', 'latest', "--add-header=x-amz-website-redirect-location:/downloads/java/realm-java-${currentVersion}.zip", "s3://static.realm.io/downloads/${link}/latest"
}
}
task uploadUpdateVersion(type: Exec) {
group = 'Release'
description = 'Update the file on S3 containing the latest version'
['java', 'android'].each() { link ->
dependsOn "upload${link.capitalize()}LatestLink"
}
commandLine 's3cmd', 'put', "${rootDir}/version.txt", 's3://static.realm.io/update/java'
}
task distribute {
group = 'Release'
description = 'Distribute release artifacts to S3'
dependsOn uploadUpdateVersion
}
task bintrayRealm(type: GradleBuild) {
description = 'Publish the Realm AAR and AP to Bintray'
group = 'Publishing'
buildFile = file('realm/build.gradle')
tasks = ['bintrayUpload']
startParameter.projectProperties = gradle.startParameter.projectProperties
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task bintrayAnnotations(type: GradleBuild) {
description = 'Publish the Realm Annotations to Bintray'
group = 'Publishing'
buildFile = file('realm-annotations/build.gradle')
startParameter.projectProperties = gradle.startParameter.projectProperties
tasks = ['bintrayUpload']
}
task bintrayGradlePlugin(type: GradleBuild) {
description = 'Publish the Realm Gradle Plugin to Bintray'
group = 'Publishing'
buildFile = file('gradle-plugin/build.gradle')
startParameter.projectProperties = gradle.startParameter.projectProperties
tasks = ['bintrayUpload']
}
task bintrayTransformer(type: GradleBuild) {
description = 'Publish the Realm Transformer to Bintray'
group = 'Publishing'
buildFile = file('realm-transformer/build.gradle')
startParameter.projectProperties = gradle.startParameter.projectProperties
tasks = ['bintrayUpload']
}
task bintrayUpload {
description = 'Publish all the Realm artifacts to Bintray'
group = 'Publishing'
dependsOn bintrayRealm
dependsOn bintrayAnnotations
dependsOn bintrayGradlePlugin
dependsOn bintrayTransformer
}
task ojoRealm(type: GradleBuild) {
description = 'Publish the Realm AAR and AP SNAPSHOT to Bintray'
group = 'Publishing'
buildFile = file('realm/build.gradle')
tasks = ['ojoUpload']
startParameter.projectProperties = gradle.startParameter.projectProperties
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
task ojoAnnotations(type: GradleBuild) {
description = 'Publish the Realm Annotations SNAPSHOT to Bintray'
group = 'Publishing'
buildFile = file('realm-annotations/build.gradle')
startParameter.projectProperties = gradle.startParameter.projectProperties
tasks = ['artifactoryPublish']
}
task ojoGradlePlugin(type: GradleBuild) {
description = 'Publish the Realm Gradle Plugin SNAPSHOT to Bintray'
group = 'Publishing'
buildFile = file('gradle-plugin/build.gradle')
startParameter.projectProperties = gradle.startParameter.projectProperties
tasks = ['artifactoryPublish']
}
task ojoTransformer(type: GradleBuild) {
description = 'Publish the Realm Transformer SNAPSHOT to Bintray'
group = 'Publishing'
buildFile = file('realm-transformer/build.gradle')
startParameter.projectProperties = gradle.startParameter.projectProperties
tasks = ['artifactoryPublish']
}
task ojoUpload {
description = 'Publish all the Realm SNAPSHOT artifacts to OJO'
group = 'Publishing'
dependsOn ojoRealm
dependsOn ojoAnnotations
dependsOn ojoGradlePlugin
dependsOn ojoTransformer
}
// This is just a placeholder for the release plugin
task build {}
release {
push = false
versionSuffix = '-SNAPSHOT'
tagPrefix = 'v'
}
task wrapper(type: Wrapper) {
gradleVersion = project.gradleVersion
}