Skip to content

Commit f38e0b0

Browse files
author
Krzysztof Borowy
committed
feat(android): add kotlin and coroutines
1 parent 0cfd502 commit f38e0b0

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

android/build.gradle

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,42 @@ def safeExtGet(prop, fallback) {
22
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
33
}
44

5+
def useDedicatedExecutor = rootProject.hasProperty('AsyncStorage_dedicatedExecutor')
6+
? rootProject.properties['AsyncStorage_dedicatedExecutor']
7+
: false
8+
9+
510
buildscript {
6-
// The Android Gradle plugin is only required when opening the android folder stand-alone.
7-
// This avoids unnecessary downloads and potential conflicts when the library is included as a
8-
// module dependency in an application project.
9-
if (project == rootProject) {
10-
repositories {
11-
google()
11+
def isRootProject = project == rootProject
12+
13+
ext.ktCoroutinesVersion = "1.3.8"
14+
15+
// kotlin version can be set by setting ext.kotlinVersion or having it in gradle.properties in root
16+
ext.asyncStorageKtVersion = rootProject.ext.has('kotlinVersion')
17+
? rootProject.ext.get('kotlinVersion')
18+
: properties['kotlinVersion']
19+
? properties['kotlinVersion']
20+
: "1.3.72"
21+
22+
repositories {
23+
if (isRootProject) {
1224
jcenter()
1325
}
14-
dependencies {
26+
google()
27+
mavenCentral()
28+
}
29+
30+
dependencies {
31+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$asyncStorageKtVersion"
32+
if (isRootProject) {
33+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
34+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
35+
// module dependency in an application project.
1536
classpath 'com.android.tools.build:gradle:3.5.0'
1637
}
1738
}
39+
40+
1841
}
1942

2043
// AsyncStorage has default size of 6MB.
@@ -24,16 +47,12 @@ buildscript {
2447
long dbSizeInMB = 6L
2548

2649
def newDbSize = rootProject.properties['AsyncStorage_db_size_in_MB']
27-
28-
if( newDbSize != null && newDbSize.isLong()) {
50+
if (newDbSize != null && newDbSize.isLong()) {
2951
dbSizeInMB = newDbSize.toLong()
3052
}
3153

32-
def useDedicatedExecutor = rootProject.hasProperty('AsyncStorage_dedicatedExecutor')
33-
? rootProject.properties['AsyncStorage_dedicatedExecutor']
34-
: false
35-
3654
apply plugin: 'com.android.library'
55+
apply plugin: 'kotlin-android'
3756

3857
android {
3958
compileSdkVersion safeExtGet('compileSdkVersion', 28)
@@ -62,4 +81,6 @@ repositories {
6281
dependencies {
6382
//noinspection GradleDynamicVersion
6483
implementation 'com.facebook.react:react-native:+' // From node_modules
84+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$asyncStorageKtVersion"
85+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$ktCoroutinesVersion"
6586
}

0 commit comments

Comments
 (0)