-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathbuild.gradle
101 lines (81 loc) · 2.55 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
group 'io.realm'
version '1.0'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_x64'
}
}
sourceSets {
main {
jniLibs.srcDirs += ["src/main/cpp/lib/"]
}
}
lintOptions {
disable 'InvalidPackage'
}
// externalNativeBuild {
// ndkBuild {
// path 'src/main/cpp/Android.mk'
// }
// }
}
def getPaths() {
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
def flutterExecutablePath = 'flutter'
if (flutterRoot != null) {
flutterExecutablePath = "${flutterRoot}${File.separator}bin${File.separator}flutter"
}
//on Windows use flutter.bat instead
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
flutterExecutablePath += '.bat'
}
return [flutterRoot, flutterExecutablePath]
}
task runMetrics(type: Exec) {
try {
def appProject = project.rootProject.subprojects.find { p -> p.name == 'app' }
def (flutterRoot, flutterExecutablePath) = getPaths()
workingDir "${project.rootProject.projectDir}${File.separator}.."
String targetOsVersion
if (appProject != null) {
def conf = appProject.android.defaultConfig
targetOsVersion = "API Level ${conf.targetSdkVersion.apiLevel}"
}
commandLine flutterExecutablePath, 'pub', 'run', 'realm', 'metrics', '--flutter-root', flutterRoot, '--target-os-type', 'android', '--target-os-version', targetOsVersion
}
catch (e) {
println "Error running metrics command $e"
}
}
task downloadRealmBinaries(type: Exec) {
def (flutterRoot, flutterExecutablePath) = getPaths()
workingDir "${project.rootProject.projectDir}${File.separator}.."
commandLine flutterExecutablePath, 'pub', 'run', 'realm', 'install', '--target-os-type', 'android', '--package-name', 'realm'
}
preBuild.dependsOn runMetrics, downloadRealmBinaries