Fix handler setters of RcsResourceObject of resource-encapsulation android api.
[platform/upstream/iotivity.git] / service / resource-encapsulation / android / service / build.gradle
1 /******************************************************************
2  *
3  * Copyright 2015 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 apply plugin: 'com.android.library'
22
23 android {
24     compileSdkVersion 21
25     buildToolsVersion "20.0.0"
26     archivesBaseName = "iotivity"
27
28     libraryVariants.all { variant ->
29         variant.outputs.each { output ->
30             def outputFile = output.outputFile
31             if (outputFile != null && outputFile.name.endsWith('.aar')) {
32                 def fileName = "${archivesBaseName}-${TARGET_ARCH}-${outputFile.name}"
33                 output.outputFile = new File(outputFile.parent, fileName)
34             }
35         }
36     }
37
38     defaultConfig {
39         minSdkVersion 21
40         targetSdkVersion 21
41         versionCode 1
42         versionName "1.0"
43     }
44     buildTypes {
45         release {
46             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47         }
48     }
49
50     lintOptions {
51        abortOnError false
52     }
53
54     sourceSets {
55         main {
56             manifest.srcFile 'src/main/AndroidManifest.xml'
57             jni.srcDirs = [] //disable automatic ndk-build call
58             jniLibs.srcDir new File(buildDir, 'native-libs')
59         }
60         androidTest.setRoot('src/androidTest')
61     }
62 }
63
64
65 dependencies {
66     compile fileTree(dir: 'libs', include: ['*.jar'])
67
68     androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
69     androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
70     androidTestCompile 'org.mockito:mockito-core:1.10.19'
71 }
72
73 ////////////////
74 ////NDK Support
75 ////////////////
76 //If using this, Android studio will fail run the following to set the environment variable for android studio:
77 //launchctl setenv ANDROID_NDK_HOME
78 //otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
79 task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
80     dependsOn 'buildNative'
81     from(new File('src/main/libs')) { include '**/*.so' exclude '**/libgnustl_shared.so' }
82     into new File(buildDir, 'native-libs')
83 }
84
85 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
86
87 clean.dependsOn 'cleanCopyNativeLibs'
88
89 tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
90     pkgTask ->
91     pkgTask.jniFolders = new HashSet<File>()
92     pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
93 }
94
95 task buildNative(type: Exec) {
96     if (System.env.ANDROID_NDK_HOME != null) {
97         //for windows use 'ndk-build.cmd'
98         //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
99         def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
100         commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE", '-C', file('src/main').absolutePath
101     } else {
102         println '##################'
103         println 'Skipping NDK build'
104         println 'Reason: ANDROID_NDK_HOME not set.'
105         println '##################'
106     }
107 }