-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
57 lines (51 loc) · 1.65 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
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task myInstallDebugApk {
doLast {
def path = rootDir.getAbsolutePath() + "/app/build/outputs/apk/debug"
def dir = new File(path)
def apkName = new String()
files(dir.listFiles()).each { file ->
if (file.name.contains("apk")) {
apkName = file.name
println "${file.name} is ready to be installed."
}
}
def apkPath = path + File.separator + apkName
def command = "adb install -r -d -t ${apkPath}" //adb instal 命令
try {
exec { //调用 exec 方法执行这个命令
ExecSpec execSpec ->
//配置闭包的内容
executable 'bash'
args '-c', command
}
println "success! installApk install success"
} catch (Exception e) {
println "failed! installApk install failed"
}
}
}