forked from mongodb/stitch-android-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
503 lines (450 loc) · 18.8 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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
def configDir = new File(rootDir, 'config')
group = 'org.mongodb'
version = VERSION
buildscript {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
repositories {
maven {
url 'http://dl.bintray.com/edaniels/gradle-plugins'
}
}
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'org.edaniels.gradle.plugin:coveralls-gradle-plugin:2.8.2'
}
}
Properties properties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
subprojects {
def projectName = project.displayName.substring(
project.displayName.indexOf(":")+1, project.displayName.length()-1).replace(":", "_")
if (["core", "server"].contains(projectName)) {
return
}
group = rootProject.group
version = rootProject.version
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'com.github.kt3k.coveralls'
buildscript {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
configurations.all {
resolutionStrategy {
force 'org.codehaus.groovy:groovy-all:2.4.12'
}
}
}
configurations {
ktlint
}
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
repositories {
maven {
url 'http://dl.bintray.com/edaniels/gradle-plugins'
}
}
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
}
dependencies {
ktlint "com.pinterest:ktlint:0.33.0"
}
ext {
min_api = 21
target_api = 28
support_library_version = '28.0.0'
google_play_services_version = '15.0.1'
kotlin_version = '1.3.21'
config_dir = configDir
}
def pomConfig = {
url "https://github.com/mongodb/stitch-android-sdk"
licenses {
license {
name "The Apache Software License, Version 2.0"
url "https://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "edaniels"
name "Eric Daniels"
email "[email protected]"
}
developer {
id "jsflax"
name "Jason Flax"
email "[email protected]"
}
developer {
id "adamchel"
name "Adam Chelminski"
email "[email protected]"
}
developer {
id "tkaye407"
name "Tyler Kaye"
email "[email protected]"
}
developer {
id "dkaminsky"
name "Doug Kaminsky"
email "[email protected]"
}
}
scm {
url "https://github.com/mongodb/stitch-android-sdk"
}
}
afterEvaluate { project ->
if (project.plugins.hasPlugin("java")) {
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
task findbugs(dependsOn: ['findbugsMain', 'findbugsTest']) {
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
test {
outputs.upToDateWhen { false }
reports.junitXml.destination = file(project.rootDir.absolutePath + "/test_results")
systemProperty "test.stitch.baseURL", properties.getProperty("test.stitch.baseURL", "http://localhost:9090")
}
javadoc {
title = "$project.name $version"
options.addStringOption("source", "8")
options.author true
options.author = true
options.version = true
options.links 'https://docs.oracle.com/javase/8/docs/api/'
options.links 'http://mongodb.github.io/mongo-java-driver/3.7/javadoc/'
options.encoding = 'UTF-8'
options.charSet 'UTF-8'
options.docEncoding 'UTF-8'
exclude '**/index.html', '**/*.kt', '**/test*/**'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier 'sources'
}
task javadocJar(type: Jar) {
from javadoc
classifier 'javadoc'
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
def displayName = project.properties.get("pomDisplayName", project.name)
root.appendNode('name', "MongoDB Stitch Android/Java SDK - $displayName")
root.appendNode('description', "MongoDB Stitch Android/Java SDK - $displayName")
root.children().last() + pomConfig
}
}
}
repositories {
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
maven {
url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username properties.getProperty("nexusUsername", "")
password properties.getProperty("nexusPassword", "")
}
}
}
}
} else if (project.plugins.hasPlugin("com.android.library")) {
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompile.classpath
}
}
exclude '**/R.html', '**/R.*.html', '**/index.html', '**/*.kt', '**/test*/**'
title = "$project.name $version"
options.addStringOption("source", "8")
options.author true
options.author = true
options.version = true
options.links 'https://docs.oracle.com/javase/8/docs/api/'
options.links 'http://mongodb.github.io/mongo-java-driver/3.7/javadoc/'
options.linksOffline "https://developers.google.com/android/reference", "${rootDir}/gradle/extDocs"
options.linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
options.encoding = 'UTF-8'
options.charSet 'UTF-8'
options.docEncoding 'UTF-8'
}
task javadocJar(type: Jar) {
from javadoc.destinationDir
classifier = 'javadoc'
}
publishing {
publications {
maven(MavenPublication) {
from components.android
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
def displayName = project.properties.get("pomDisplayName", project.name)
root.appendNode('name', "MongoDB Stitch Android/Java SDK - $displayName")
root.appendNode('description', "MongoDB Stitch Android/Java SDK - $displayName")
root.children().last() + pomConfig
}
}
}
repositories {
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
maven {
url = project.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username properties.getProperty("nexusUsername", "")
password properties.getProperty("nexusPassword", "")
}
}
}
}
coveralls {
jacocoReportPath = 'build/reports/coverage/debug/report.xml'
}
}
tasks.withType(FindBugs) {
effort = 'max'
reports {
xml.enabled = false
html.enabled = true
html.setDestination new File("$project.buildDir/outputs/findbugs/$projectName-findbugs.html")
}
excludeFilter = new File(configDir, 'findbugs-exclude.xml')
}
if (project.plugins.hasPlugin("com.jfrog.bintray")) {
def user = properties.getProperty("publish.bintray.user", "")
def apiKey = properties.getProperty("publish.bintray.apiKey", "")
def gpgPassphrase = properties.getProperty("publish.bintray.gpgPassphrase", "")
def mavenSyncUser = properties.getProperty("publish.bintray.mavenSyncUser", "")
def mavenSyncPassword = properties.getProperty("publish.bintray.mavenSyncPassword", "")
bintray {
owner.user = user
key = apiKey
publish = true
override = false
pkg {
repo = 'MongoDB'
name = "$rootProject.group:$project.name"
userOrg = 'mongodb'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/mongodb/stitch-android-sdk.git'
githubRepo = 'mongodb/stitch-android-sdk'
githubReleaseNotesFile = 'README.md'
websiteUrl = 'https://www.mongodb.com/cloud/stitch'
publicDownloadNumbers = true
version {
name = rootProject.version
released = new Date()
if (!gpgPassphrase.isEmpty()) {
gpg {
sign = true
passphrase = gpgPassphrase
}
}
if (!mavenSyncUser.isEmpty()) {
mavenCentralSync {
sync = true
owner.user = mavenSyncUser
password = mavenSyncPassword
close = '1'
}
}
}
}
publications = ['maven']
}
task publishSnapshots {
group = 'publishing'
description = 'Publishes snapshots to Sonatype'
if (version.endsWith('-SNAPSHOT')) {
dependsOn tasks.withType(PublishToMavenRepository)
}
}
}
}
checkstyle {
toolVersion = "8.10"
configFile = new File(configDir, 'checkstyle.xml')
configProperties.checkstyleConfigDir = configDir
}
task checkstyle(type: Checkstyle) {
configFile = new File(configDir, 'checkstyle.xml')
configProperties.checkstyleConfigDir = configDir
source 'src/main/java', 'src/test/java'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
reports {
xml.enabled = false
html.enabled = true
html.setDestination new File("$project.buildDir/outputs/checkstyle/$projectName-checkstyle.html")
}
}
pmd {
toolVersion = "6.12.0"
ruleSetFiles = files("$configDir/pmd.xml")
ruleSets = []
ignoreFailures = true
}
task pmd(type: Pmd) {
source 'src/main/java', 'src/test/java'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
html.setDestination new File("$project.buildDir/outputs/pmd/$projectName-pmd.html")
}
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
task install(dependsOn: 'publishToMavenLocal')
}
def corePackages = ["com.mongodb.stitch.core",
"com.mongodb.stitch.core.auth",
"com.mongodb.stitch.core.auth.providers.anonymous",
"com.mongodb.stitch.core.auth.providers.custom",
"com.mongodb.stitch.core.auth.providers.facebook",
"com.mongodb.stitch.core.auth.providers.google",
"com.mongodb.stitch.core.auth.providers.serverapikey",
"com.mongodb.stitch.core.auth.providers.userapikey",
"com.mongodb.stitch.core.auth.providers.userapikey.models",
"com.mongodb.stitch.core.auth.providers.userpassword",
"com.mongodb.stitch.core.services.aws.s3",
"com.mongodb.stitch.core.services.aws.ses",
"com.mongodb.stitch.core.services.fcm",
"com.mongodb.stitch.core.services.http",
"com.mongodb.stitch.core.services.mongodb.remote"]
def androidPackages = ["com.mongodb.stitch.android.core",
"com.mongodb.stitch.android.core.auth",
"com.mongodb.stitch.android.core.auth.providers.userapikey",
"com.mongodb.stitch.android.core.auth.providers.userpassword",
"com.mongodb.stitch.android.core.services",
"com.mongodb.stitch.android.services.aws.s3",
"com.mongodb.stitch.android.services.aws.ses",
"com.mongodb.stitch.android.services.fcm",
"com.mongodb.stitch.android.services.http",
"com.mongodb.stitch.android.services.mongodb.local",
"com.mongodb.stitch.android.services.mongodb.remote",
"com.mongodb.stitch.android.services.twilio"]
def serverPackages = ["com.mongodb.stitch.server.core",
"com.mongodb.stitch.server.core.auth",
"com.mongodb.stitch.server.core.auth.providers.userapikey",
"com.mongodb.stitch.server.core.auth.providers.userpassword",
"com.mongodb.stitch.server.core.services",
"com.mongodb.stitch.server.services.aws.s3",
"com.mongodb.stitch.server.services.aws.ses",
"com.mongodb.stitch.server.services.fcm",
"com.mongodb.stitch.server.services.http",
"com.mongodb.stitch.server.services.mongodb.remote",
"com.mongodb.stitch.server.services.twilio"]
rootProject.gradle.projectsEvaluated {
task allJavadocs(type: Javadoc, group: 'Documentation') {
destinationDir = file("$buildDir/docs/javadoc")
title = "MongoDB Stitch Java SDK $version API"
options.author true
options.author = true
options.version = true
options.links 'https://docs.oracle.com/javase/8/docs/api/'
options.links 'http://mongodb.github.io/mongo-java-driver/3.7/javadoc/'
options.linksOffline "https://developers.google.com/android/reference", "${rootDir}/gradle/extDocs"
options.encoding = 'UTF-8'
options.charSet 'UTF-8'
options.docEncoding 'UTF-8'
options.group "Android SDK", androidPackages.join(':')
options.group "Server SDK", serverPackages.join(':')
options.group "Core SDK", corePackages.join(':')
if (project.hasProperty("analytics")) {
println "Building with analytics."
options.addStringOption("top", new File(configDir, 'header.html').text)
options.addBooleanOption("-allow-script-in-comments", true)
// Note: despite multiple --add-stylesheet flags being allowed on command line,
// there is no apparent way to add multiple stylesheets via this options object.
options.addFileOption("-add-stylesheet", new File(rootDir, 'contrib/assets/css/javadoc-main.css'))
} else {
println "Building without analytics. Use -Panalytics to enable analytics."
}
options.doclet = "CodeExampleManifestDoclet"
options.docletpath new File(rootDir, "contrib/doclet/bin/")
options.addStringOption("examplesPath", "contrib/docs-examples/")
options.addStringOption("manifestPath", "build/docs/examplesManifest.json")
// Appease 'unnamed module' error on javadoc 11.0.2+
options.addStringOption("source", "8")
String androidDocsDir = ""
subprojects {
project.tasks.withType(Javadoc).each { javadocTask ->
source += javadocTask.source
classpath += javadocTask.classpath
excludes += javadocTask.excludes
includes += javadocTask.includes
if (project.hasProperty("android")) {
androidDocsDir = "${android.sdkDirectory}/docs/reference"
}
}
}
if (!androidDocsDir.isEmpty()) {
options.linksOffline "http://d.android.com/reference", androidDocsDir
}
}
}