Merge test folder of test branch
[iotivity.git] / test / src / tc / cs / junit / build.gradle
1 /******************************************************************
2  *
3  * Copyright 2018 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 buildscript {
22     repositories {
23         jcenter()
24     }
25     dependencies {
26         classpath 'com.android.tools.build:gradle:1.5.0'
27     }
28 }
29
30 task csbuild (dependsOn:['assemble']){
31
32     project.buildDir =  binDir
33
34     repositories {
35         mavenCentral()
36
37         flatDir{
38             if("${src_type}" == "java") {
39                 dirs "${iotivity_root}/java/iotivity-java/build/libs"
40             } else {
41                 dirs "${iotivity_root}/java/iotivity-android/build/outputs/aar"
42             }
43         }
44     }
45
46     def javaType = 'generic'
47
48     if(src_type == 'android') {
49         javaType = 'android'
50     }
51
52     def commonSrcDir = ['./src/org/iotivity/test/' + module_name + '/tc',
53                         '../../../../src/common/commonutil/java/java-' + javaType + '/iotivityhelpers/ri',
54                         '../../../../src/common/commonutil/java/java-' + javaType + '/cloud',
55                         '../../../../src/common/commonutil/java/java-' + javaType + '/logger',
56                         '../../../../src/common/commonutil/java/java-' + javaType + '/testcase',
57                         '../../../../src/common/commonutil/java/common/resource',
58                         '../../../../src/common/commonutil/java/common/util'
59     ]
60
61     def printSrcDir = { listParam ->
62          println '------------------\nSource Directories\n------------------'
63          listParam.eachWithIndex { item, index ->
64              println "    " + item
65          }
66     }
67
68     def buildFatJar = { isJava ->
69         //delete project.buildDir
70
71         if(isJava == "java") {
72             apply plugin: 'java'
73             sourceSets {
74                 main {
75                     java {
76                         srcDirs += commonSrcDir
77                         srcDirs '../../../../src/common/testcase/junit/'
78                         printSrcDir(srcDirs)
79                     }
80                 }
81             }
82
83             dependencies {
84                 compile fileTree(dir: "${iotivityRoot}/out/${os}/${architecture}/${logLevel}/java", include: ['*.jar'])
85                 compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
86                 compile group: 'junit', name: 'junit', version: '4.12'
87             }
88
89             jar {
90                 archiveName module_name + '_test.jar'
91                 from {
92                 (configurations.runtime).collect { it.isDirectory() ? it : zipTree(it)}
93                 }
94
95                 manifest {
96                     attributes('Main-Class': 'org.iotivity.test.IotivityJunitRunner')
97                 }
98             }
99
100             copy {
101                 from testRoot + '/res/cs_resource/'
102                 into testRoot + '/bin/java/cs/libs/'
103             }
104
105             copy {
106                 from testRoot + '/res/common/'
107                 into testRoot + '/bin/java/cs/libs/'
108             }
109         } else {
110             apply plugin: 'com.android.application'
111             android {
112                 compileSdkVersion  21
113                 buildToolsVersion "21.1.2"
114
115                 sourceSets {
116                     main {
117                         java {
118                             manifest.srcFile 'AndroidManifest.xml'
119                             srcDirs += commonSrcDir
120                             srcDirs '../../../../src/common/commonutil/java/java-android/broadcast/'
121                             printSrcDir(srcDirs)
122                        }
123                     }
124
125                 }
126
127                 lintOptions {
128                     abortOnError false
129                 }
130
131                 defaultConfig {
132                     applicationId 'org.iotivity.test.' + module_name + '.tc'
133                     minSdkVersion 21
134                     targetSdkVersion 21
135                 }
136             }
137
138             dependencies {
139                 compile fileTree(dir: "${javaExtLibDir}", include: ['*.jar'])
140                 compile(name:"${iotivityBaseAARFile}", ext:'aar')
141             }
142         }
143     }
144
145     buildFatJar(src_type)
146 }