forked from realm/realm-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
377 lines (329 loc) · 11.5 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
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.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 = ['install']
}
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 = ['install']
}
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')]
}
}
task check(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 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 = ['install']
if (project.hasProperty('buildTargetABIs')) {
startParameter.projectProperties += [buildTargetABIs: project.getProperty('buildTargetABIs')]
}
}
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 = ['install']
}
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/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-jni/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 uploadDistributionPackage(type: Exec) {
group = 'Release'
description = 'Upload the distribution package to S3'
dependsOn distributionPackage
dependsOn distributionJniUnstrippedPackage
commandLine 's3cmd', 'put', "${buildDir}/outputs/distribution/realm-java-${currentVersion}.zip", 's3://static.realm.io/downloads/java/'
commandLine 's3cmd', 'put', "${buildDir}/outputs/distribution/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']
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')
tasks = ['bintrayUpload']
}
task bintrayGradlePlugin(type: GradleBuild) {
description = 'Publish the Realm Gradle Plugin to Bintray'
group = 'Publishing'
buildFile = file('gradle-plugin/build.gradle')
tasks = ['bintrayUpload']
}
task bintrayTransformer(type: GradleBuild) {
description = 'Publish the Realm Transformer to Bintray'
group = 'Publishing'
buildFile = file('realm-transformer/build.gradle')
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 = ['artifactoryPublish']
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')
tasks = ['artifactoryPublish']
}
task ojoGradlePlugin(type: GradleBuild) {
description = 'Publish the Realm Gradle Plugin SNAPSHOT to Bintray'
group = 'Publishing'
buildFile = file('gradle-plugin/build.gradle')
tasks = ['artifactoryPublish']
}
task ojoTransformer(type: GradleBuild) {
description = 'Publish the Realm Transformer SNAPSHOT to Bintray'
group = 'Publishing'
buildFile = file('realm-transformer/build.gradle')
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
}