This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
build.gradle
151 lines (129 loc) · 3.87 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
apply plugin: 'com.android.application'
// apply AFTER android plugin
apply plugin: 'com.novoda.android-command'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
}
buildTypes {
release.signingConfig debug.signingConfig
QA.signingConfig debug.signingConfig
}
productFlavors {
flavorDimensions 'pricing', 'releaseType'
beta {
dimension 'releaseType'
}
normal {
dimension 'releaseType'
}
free {
dimension 'pricing'
}
paid {
dimension 'pricing'
}
}
command {
deviceId {
def apiLevel = defaultConfig.minSdkVersion.getApiLevel()
def minSdkDevice = devices().find { it.sdkVersion() >= apiLevel }
if (!minSdkDevice) {
throw new IllegalStateException("No device found running android version >= ${apiLevel}")
}
minSdkDevice.id
}
monkey {
events 1000
categories 'android.intent.category.ONLY_ME', 'android.intent.category.MONKEY'
}
// More info: https://github.com/novoda/gradle-android-command-plugin#input-scripting
scripts {
autoLogin {
execute {
2.times {
text 'bob'
enter()
}
enter()
}
}
pressBack.execute {
back()
}
}
// More info: https://github.com/novoda/gradle-android-command-plugin#demo-mode
demoMode {
clock.hhmm '1134'
network {
wifi 'show'
level '3'
}
}
// More info: https://github.com/novoda/gradle-android-command-plugin#install
install {
fromGooglePlay {
description "Installs with flag Play Store"
// Note: here flags are lazy evaluated
customFlags {
['-i', 'com.android.vending']
}
}
allowingDowngrade {
description "Installs with -d flag"
customFlags = ['-d']
}
currentUser.customFlags = ['--user', 'current']
}
}
}
task listDevices doLast {
println 'Attached devices:'
android.command.devices().each {
println it
}
}
task dumpActivityStack(type: com.novoda.gradle.command.ActivityStack)
/**
* Sample task that installs APKs of all variants on a device.
*
* Device can also be specified like below:
* ./gradlew installDeviceAllVariants -DdeviceId=SERIAL_NUMBER
*/
def installAllTask = task installDeviceAllVariants {
description = 'Install APKs for all variants on a specified device'
group = 'install'
}
android.applicationVariants.all {
installAllTask.dependsOn tasks.findByName("installDevice${it.name.capitalize()}")
}
/**
* Uses the Files task type to backup photos on the device to
* some local directory.
* Only pulls files that are not yet backed up.
*/
task syncPhotos(type: com.novoda.gradle.command.Files) {
deviceId {
def moto = android.command.devices().find { it.brand() == 'motorola' }
if (!moto) {
throw new GroovyRuntimeException('No Motorola device found')
}
moto.id
}
script {
def deviceImageDir = '/sdcard/DCIM/Camera/'
def backupDir = mkdir('motoPhoto')
list(deviceImageDir).findAll { image ->
image.name.endsWith('jpg') && !image.name.contains(':nopm:')
}
.findAll { image ->
!new File(backupDir.path, image.name).exists()
}
.each { image ->
println image
pull image.path + image.name, backupDir.path
}
}
}