/
build.gradle
162 lines (133 loc) · 5.3 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
// `react-native run-android` is hard-coded to look for the output APK at a very
// specific location. See
// https://github.com/react-native-community/cli/blob/6cf12b00c02aca6d4bc843446394331d71a9749e/packages/platform-android/src/commands/runAndroid/index.ts#L180
buildDir = "$rootDir/$name/build"
def reactNativeDir = findNodeModulesPath(rootDir, "react-native")
buildscript {
def androidDir = "${buildscript.sourceFile.getParent()}/../"
apply from: "$androidDir/test-app-util.gradle"
apply from: "$androidDir/dependencies.gradle"
repositories {
google()
mavenCentral()
}
}
repositories {
maven {
url("${reactNativeDir}/android")
}
google()
mavenCentral()
// TODO: Remove these when they've been published to Maven Central.
// See https://github.com/microsoft/react-native-test-app/issues/305
// noinspection JcenterRepositoryObsolete
jcenter() {
content {
includeGroup("com.facebook.fbjni")
includeGroup("com.facebook.flipper")
includeGroup("com.facebook.fresco")
includeGroup("com.facebook.yoga")
}
}
}
apply from: "$projectDir/../force-resolve-trove4j.gradle"
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "kotlin-kapt"
def testAppDir = file("$projectDir/../../")
apply from: file("${testAppDir}/test-app.gradle")
applyTestAppModule(project)
project.ext.react = [
appName : getAppName(),
applicationId: getApplicationId(),
enableFlipper: getFlipperVersion(rootDir),
enableHermes : true,
]
android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
// We need only set `ndkVersion` when building react-native from source.
if (hasProperty("ANDROID_NDK_VERSION")) {
ndkVersion ANDROID_NDK_VERSION
}
// TODO: Remove this block when minSdkVersion >= 24. See
// https://stackoverflow.com/q/53402639 for details.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId project.ext.react.applicationId
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
versionCode reactTestApp.versionCode
versionName reactTestApp.versionName
def recommendedFlipperVersion = getFlipperRecommendedVersion(rootDir)
buildConfigField "String",
"ReactTestApp_recommendedFlipperVersion",
recommendedFlipperVersion ? "\"${recommendedFlipperVersion}\"" : '"0"'
resValue "string", "app_name", project.ext.react.appName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
packagingOptions {
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
pickFirst "lib/x86/libc++_shared.so"
}
sourceSets {
if (project.ext.react.enableFlipper) {
debug.java.srcDirs += 'src/flipper/java'
}
}
}
dependencies {
implementation project(":support")
if (project.ext.react.enableHermes) {
def hermesEngineDir =
findNodeModulesPath(file(reactNativeDir), "hermes-engine")
?: findNodeModulesPath(file(reactNativeDir), "hermesvm")
if (hermesEngineDir == null) {
throw new GradleException("Could not find 'hermes-engine'. Please make sure you've added it to 'package.json'.")
}
def hermesAndroidDir = "$hermesEngineDir/android"
releaseImplementation files("$hermesAndroidDir/hermes-release.aar")
debugImplementation files("$hermesAndroidDir/hermes-debug.aar")
}
if (buildReactNativeFromSource(rootDir)) {
implementation project(':ReactAndroid')
} else {
implementation "com.facebook.react:react-native:+"
}
implementation libraries.kotlinStdlibJdk7
implementation libraries.kotlinStdlibJdk8
implementation libraries.kotlinReflect
implementation libraries.androidAppCompat
implementation libraries.androidCoreKotlinExtensions
implementation libraries.androidRecyclerView
implementation libraries.androidSwipeRefreshLayout
implementation libraries.materialComponents
implementation libraries.moshiKotlin
kapt libraries.moshiKotlinCodegen
testImplementation libraries.junit
testImplementation libraries.androidJUnitKotlinExtensions
testImplementation libraries.mockitoInline
androidTestImplementation libraries.androidJUnit
androidTestImplementation libraries.androidEspressoCore
if (project.ext.react.enableFlipper) {
def flipperVersion = project.ext.react.enableFlipper
debugImplementation("com.facebook.flipper:flipper:${flipperVersion}") {
exclude group: 'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${flipperVersion}") {
exclude group: 'com.facebook.flipper'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${flipperVersion}") {
exclude group: 'com.facebook.flipper'
}
}
}