1
+ /*
2
+ * run from dir: test-app/
3
+ * run on emulator: ./gradlew runtests //default
4
+ * run on device: ./gradlew runtests -PrunOnDevice
5
+ *
6
+ */
7
+
8
+
9
+ def isWinOs = System . properties[' os.name' ]. toLowerCase(). contains(' windows' )
10
+
11
+ apply plugin : ' com.android.model.application'
12
+
13
+ def runOnDevice = project. hasProperty(" runOnDevice" );
14
+ def runOnDeviceOrEmulator = runOnDevice ? " -d" : " -e" ;
15
+
16
+ model {
17
+ android {
18
+ compileSdkVersion = 25
19
+ buildToolsVersion = " 25.0.2"
20
+
21
+ defaultConfig. with {
22
+ applicationId = " com.tns.debugapp"
23
+ minSdkVersion. apiLevel = 17
24
+ targetSdkVersion. apiLevel = 22
25
+ versionCode = 1
26
+ versionName = " 1.0"
27
+ }
28
+
29
+ lintOptions. with {
30
+ abortOnError = false
31
+ }
32
+ }
33
+
34
+ // android.ndk {
35
+ // moduleName = "test-app-dummy-native-lib"
36
+ // }
37
+
38
+ android. buildTypes {
39
+ release {
40
+ minifyEnabled = false
41
+ proguardFiles. add(file(' proguard-rules.txt' ))
42
+ }
43
+ }
44
+ }
45
+
46
+ dependencies {
47
+ def supportVer = " 23.3.0"
48
+ compile project(' :runtime' )
49
+ compile fileTree(include : [' *.jar' ], dir : ' libs' )
50
+
51
+ compile " com.android.support:support-v4:$supportVer "
52
+ compile " com.android.support:appcompat-v7:$supportVer "
53
+ compile " com.android.support:design:$supportVer "
54
+
55
+ testCompile ' junit:junit:4.12'
56
+ }
57
+
58
+ repositories {
59
+ jcenter()
60
+ flatDir {
61
+ dirs ' src/F0' , ' src/F1' ,
62
+ ' src/F2' , ' src/F3' ,
63
+ ' src/F4' , ' src/F5' ,
64
+ ' src/F6' , ' src/F7' ,
65
+ ' src/F8' , ' src/F9' ,
66
+ ' src/F10' , ' src/F11'
67
+ }
68
+ }
69
+
70
+ task addAarDependencies {
71
+ FileTree tree = fileTree(dir : " $projectDir /src" , include : [" **/*.aar" ])
72
+ tree. each { File file ->
73
+ // remove the extension of the file (.aar)
74
+ def length = file. name. length() - 4
75
+ def fileName = file. name[0 .. < length]
76
+ println " \t +adding dependency: " + file. getAbsolutePath()
77
+ project. dependencies. add(" compile" , [name : fileName, ext : " aar" ])
78
+ }
79
+ }
80
+
81
+ // ///////////////////////////// installing application ////////////////////////////
82
+
83
+ task installApk (type : Exec ) {
84
+ doFirst {
85
+ println " Attempting to install buit apk"
86
+
87
+ if (isWinOs) {
88
+ commandLine " cmd" , " /c" , " node" , " $rootDir \\ tools\\ deploy-apk.js" , " $rootDir \\ runtimedebug\\ build\\ outputs\\ apk\\ app-debug.apk"
89
+ } else {
90
+ commandLine " node" , " $rootDir /tools/deploy-apk.js" , " $rootDir /runtimedebug/build/outputs/apk/app-debug.apk"
91
+ }
92
+ }
93
+
94
+ doLast {
95
+ println " Install result:" + execResult
96
+ }
97
+ }
98
+
99
+ task startInstalledApk (type : Exec ) {
100
+ doFirst {
101
+ println " Starting test application"
102
+
103
+ if (isWinOs) {
104
+ commandLine " cmd" , " /c" , " adb" , " shell" , " am" , " start" , " -n" , " org.nativescript.runtimedebug/com.tns.NativeScriptActivity" , " -a" , " android.intent.action.MAIN" , " -c" , " android.intent.category.LAUNCHER"
105
+ } else {
106
+ commandLine " adb" , " shell" , " am" , " start" , " -n" , " org.nativescript.runtimedebug/com.tns.NativeScriptActivity" , " -a" , " android.intent.action.MAIN" , " -c" , " android.intent.category.LAUNCHER"
107
+ }
108
+ }
109
+ }
110
+
111
+ startInstalledApk. dependsOn(installApk)
112
+
113
+ task deleteDist (type : Delete ) {
114
+ doFirst {
115
+ delete " $rootDir /dist"
116
+ }
117
+ }
0 commit comments