-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
74 lines (62 loc) · 2.29 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
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.9/samples
* This project uses @Incubating APIs which are subject to change.
*/
plugins {
id 'com.android.application' version '8.5.0' apply false
id 'com.android.library' version '8.5.0' apply false
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.4"
}
layout.buildDirectory.set(layout.projectDirectory.dir("target/gradleBuild"))
task buildDebug {
description = "Build the Apk for Debug"
dependsOn ":app:assembleDebug"
}
task reversePort(type: Exec) {
description = "adb reverse port"
dependsOn ":app:assembleDebug"
def from = findProperty("adb.portFrom")
def to = findProperty("adb.portTo")
def runCommand = ['adb', 'reverse', from, to]
commandLine runCommand
}
task launchDebug(type: Exec) {
description = "Install then launch the Apk for Debug"
dependsOn ":app:installDebug"
def packageS = findProperty("android.applicationId")
def main = findProperty("android.main")
def runCommand = ['adb', '-d', 'shell', 'am', 'start', '-a', 'android.intent.action.MAIN', '-n', packageS + "/" + main]
commandLine runCommand
}
task getUid {
description = "Print the adb logcat command for this Apk"
dependsOn launchDebug
doLast {
def packageS = findProperty("android.applicationId")
def logcatCmd = "./logcat.cmd"
def fileContents = new File(logcatCmd).getText()
new ByteArrayOutputStream().withStream { uid ->
def result = exec {
commandLine = ['adb', '-d', 'shell', 'pm', 'list', 'package', '-U', packageS]
standardOutput = uid
}
def app_uid = uid.toString().tokenize(':')[-1]
def logcat = 'adb logcat -v color --uid ' + app_uid.toString()
if (fileContents.contains('adb logcat')) {
new File(logcatCmd).text = logcat
} else {
logger.error('File ' + logcatCmd + ' must contain "abi logcat" ')
}
}
}
}
task run {
dependsOn "getUid"
}
tasks.register("buildRelease") {
description = "Build the Apk for Release"
dependsOn ":app:assembleDebug"
}