forked from realm/realm-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
441 lines (396 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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1'
classpath 'ch.netzwerg:gradle-release-plugin:1.2.0'
}
}
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
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 assembleGradlePlugin(type:GradleBuild) {
group = 'Build'
description = 'Assemble the Realm Gradle plugin'
buildFile = file('gradle-plugin/build.gradle')
tasks = ['assemble']
}
task assembleRealm(type:GradleBuild) {
group = 'Build'
description = 'Assemble the Realm project'
buildFile = file('realm/build.gradle')
tasks = ['assemble', 'javadocJar', 'sourcesJar']
}
task check(type:GradleBuild) {
group = 'Test'
description = 'Run the JVM tests and checks Realm project'
buildFile = file('realm/build.gradle')
tasks = ['check']
}
task connectedCheck(type:GradleBuild) {
group = 'Test'
description = 'Run the Android unit tests of the Realm project'
buildFile = file('realm/build.gradle')
tasks = ['connectedCheck']
}
task installGradlePlugin(type:GradleBuild) {
description = 'Install the Realm Gradle plugin into mavenLocal()'
group = 'Install'
buildFile = file('gradle-plugin/build.gradle')
tasks = ['install']
}
task installRealm(type:GradleBuild) {
group = 'Install'
description = 'Install the artifacts of Realm project into mavenLocal()'
buildFile = file('realm/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']
}
task sourcesJar(type:GradleBuild) {
description = 'Generate the sources Jar for the Realm project'
group = 'Docs'
buildFile = file('realm/build.gradle')
tasks = ['sourcesJar']
}
task eclipseJar(type:GradleBuild) {
description = 'Generate the Jar file to be used with Eclipse'
group = 'Artifact'
buildFile = file('realm/build.gradle')
tasks = ['shadowJar']
}
task gradleJar(type:Zip) {
description = 'Generate the jar file to be used with Gradle'
group = 'Artifact'
dependsOn eclipseJar
archiveName = "realm-android-${currentVersion}.jar"
destinationDir = file("${buildDir}/outputs/gradle")
from(zipTree("realm/realm-annotations-processor/build/libs/realm-android-${currentVersion}.jar"))
from('realm/realm-library/src/main/jniLibs/') {
include '**/*'
into 'lib'
}
}
task assemble {
group 'Build'
description = 'Build Realm, the Gradle plugin and the examples'
dependsOn assembleExamples
dependsOn gradleJar
}
task distributionPackage(type:Zip) {
description = 'Generate the distribution package'
dependsOn gradleJar
dependsOn assembleRealm
dependsOn javadoc
dependsOn eclipseJar
group = 'Artifact'
archiveName = "realm-java-${currentVersion}.zip"
destinationDir = file("${buildDir}/outputs/distribution")
from('changelog.txt')
from('LICENSE')
from('version.txt')
from('realm/realm-annotations-processor/build/libs') {
include "realm-android-${currentVersion}.jar"
into 'eclipse'
}
from('realm/realm-library/src/main/jniLibs/') {
include '**/*'
into 'eclipse'
}
from("${buildDir}/outputs/gradle") {
include "realm-android-${currentVersion}.jar"
into 'gradle'
}
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 cleanRealm(type:GradleBuild) {
description = 'Clean the Realm project'
group = 'Clean'
buildFile = file('realm/build.gradle')
tasks = ['clean']
if (project.hasProperty('dontCleanJniFiles')) {
startParameter.projectProperties = [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'
dependsOn cleanRealm
dependsOn cleanGradlePlugin
dependsOn cleanExamples
dependsOn cleanLocalMavenRepos
}
task uploadDistributionPackage(type: Exec) {
group = 'Release'
description = 'Upload the distribution package to S3'
dependsOn distributionPackage
commandLine 's3cmd', 'put', "${buildDir}/outputs/distribution/realm-java-${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
}
// This is a work-around for a bug in the publish plugin that prevents publishing the same artifact twice in two
// different publications
task duplicateSourcesAndJavadoc(type: Copy) {
description = 'Prepare source and javadoc jars for publishing.'
group = 'Publishing'
dependsOn sourcesJar
dependsOn javadoc
from("${rootDir}/realm/realm-library/build/libs/") {
include '*.jar'
rename 'realm-android-library-(.*?)', 'realm-android-$1'
}
into "${rootDir}/realm/realm-library/build/libs/"
}
task bintrayAar(type: GradleBuild) {
description = 'Publish the Realm AAR to Bintray'
group = 'Distribute'
dependsOn duplicateSourcesAndJavadoc
buildFile = file('bintrayAar.gradle')
tasks = ['bintrayUpload']
}
task bintrayJar(type: GradleBuild) {
description = 'Publish the Realm Jar to Bintray'
group = 'Distribute'
dependsOn duplicateSourcesAndJavadoc
buildFile = file('bintrayJar.gradle')
tasks = ['bintrayUpload']
}
task bintrayAnnotations(type: GradleBuild) {
description = 'Publish the Realm Annotations to Bintray'
group = 'Distribute'
buildFile = file('bintrayAnnotations.gradle')
tasks = ['bintrayUpload']
}
task bintrayAnnotationsProcessor(type: GradleBuild) {
description = 'Publish the Realm AP to Bintray'
group = 'Distribute'
buildFile = file('bintrayAnnotationsProcessor.gradle')
tasks = ['bintrayUpload']
}
task bintrayGradlePlugin(type: GradleBuild) {
description = 'Publish the Realm Gradle Plugin to Bintray'
group = 'Distribute'
buildFile = file('bintrayGradlePlugin.gradle')
tasks = ['bintrayUpload']
}
task bintrayUpload {
description = 'Publish all the Realm artifacts to Bintray'
group = 'Distribute'
dependsOn bintrayAar
dependsOn bintrayJar
dependsOn bintrayAnnotations
dependsOn bintrayAnnotationsProcessor
dependsOn bintrayGradlePlugin
}
task ojoUpload {
description = 'Publish all the Realm SNAPSHOT artifacts to OJO'
group = 'Publishing'
dependsOn duplicateSourcesAndJavadoc
dependsOn artifactoryPublish
artifactoryPublish.dependsOn duplicateSourcesAndJavadoc
}
// This is just a placeholder for the release plugin
task build {}
def commonPom = {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
issueManagement {
system 'github'
url 'https://github.com/realm/realm-java/issues'
}
scm {
url 'scm:https://github.com/realm/realm-java'
connection 'scm:[email protected]:realm/realm-java.git'
developerConnection 'scm:[email protected]:realm/realm-java.git'
}
}
publishing {
publications {
jarLibrary(MavenPublication) {
groupId 'io.realm'
artifactId = 'realm-android'
artifact file("${buildDir}/outputs/gradle/realm-android-${currentVersion}.jar")
artifact(file("${rootDir}/realm/realm-library/build/libs/realm-android-${currentVersion}-sources.jar")) {
classifier = 'sources'
}
artifact(file("${rootDir}/realm/realm-library/build/libs/realm-android-${currentVersion}-javadoc.jar")) {
classifier = 'javadoc'
}
pom.withXml {
Node root = asNode()
root.appendNode('name', 'realm-android')
root.appendNode('description', 'Realm is a mobile database: a replacement for SQLite & ORMs.')
root.appendNode('url', 'http://realm.io')
root.children().last() + commonPom
}
}
aarLibrary(MavenPublication) {
groupId 'io.realm'
artifactId = 'realm-android-library'
artifact file("${rootDir}/realm/realm-library/build/outputs/aar/realm-android-library-release.aar")
artifact(file("${rootDir}/realm/realm-library/build/libs/realm-android-library-${currentVersion}-sources.jar")) {
classifier = 'sources'
}
artifact(file("${rootDir}/realm/realm-library/build/libs/realm-android-library-${currentVersion}-javadoc.jar")) {
classifier = 'javadoc'
}
pom.withXml {
Node root = asNode()
root.appendNode('name', 'realm-android-library')
root.appendNode('description', 'Realm is a mobile database: a replacement for SQLite & ORMs.')
root.appendNode('url', 'http://realm.io')
root.children().last() + commonPom
}
}
annotations(MavenPublication) {
groupId 'io.realm'
artifactId = 'realm-annotations'
artifact file("${rootDir}/realm/realm-annotations/build/libs/realm-annotations-${currentVersion}.jar")
pom.withXml {
Node root = asNode()
root.appendNode('name', 'realm-annotations')
root.appendNode('description', 'Annotations for Realm. Realm is a mobile database: a replacement for SQLite & ORMs')
root.appendNode('url', 'http://realm.io')
root.children().last() + commonPom
}
}
annotationsProcessor(MavenPublication) {
groupId 'io.realm'
artifactId = 'realm-annotations-processor'
artifact file("${rootDir}/realm/realm-annotations-processor/build/libs/realm-annotations-processor-${currentVersion}.jar")
pom.withXml {
Node root = asNode()
root.appendNode('name', 'realm-annotations-processor')
root.appendNode('description', 'Annotation Processor for Realm. Realm is a mobile database: a replacement for SQLite & ORMs')
root.appendNode('url', 'http://realm.io')
root.children().last() + commonPom
}
}
gradlePlugin(MavenPublication) {
groupId 'io.realm'
artifactId = 'realm-gradle-plugin'
artifact file("${rootDir}/gradle-plugin/build/libs/realm-gradle-plugin-${currentVersion}.jar")
pom.withXml {
Node root = asNode()
root.appendNode('name', 'realm-realm-plugin')
root.appendNode('description', 'Gradle plugin for Realm. Realm is a mobile database: a replacement for SQLite & ORMs.')
root.appendNode('url', 'http://realm.io')
root.children().last() + commonPom
}
}
}
}
artifactory {
contextUrl = 'https://oss.jfrog.org/artifactory'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = project.hasProperty('bintrayUser') ? bintrayUser : 'noUser'
password = project.hasProperty('bintrayKey') ? bintrayKey : 'noKey'
}
defaults {
publications ('jarLibrary', 'aarLibrary', 'annotations', 'annotationsProcessor', 'gradlePlugin')
}
}
}
release {
push = false
versionSuffix = '-SNAPSHOT'
tagPrefix = 'v'
}
task wrapper(type: Wrapper) {
gradleVersion = project.gradleVersion
}