replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / android / notification-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     repositories {        
45         flatDir {
46             dirs '../../../../android/android_api/base/build/outputs/aar'
47         }
48     }
49     buildTypes {
50         release {
51             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
52         }
53     }
54
55     lintOptions {
56        abortOnError false
57     }
58
59     sourceSets {
60         main {
61             manifest.srcFile 'src/main/AndroidManifest.xml'
62             jni.srcDirs = [] //disable automatic ndk-build call
63             jniLibs.srcDir new File(buildDir, 'native-libs')
64         }
65         androidTest.setRoot('src/androidTest')
66     }
67 }
68
69
70 dependencies {
71     compile fileTree(dir: 'libs', include: ['*.jar'])
72     compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"
73     androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
74     androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
75     androidTestCompile 'org.mockito:mockito-core:1.10.19'
76 }
77
78 ////////////////
79 ////NDK Support
80 ////////////////
81 //If using this, Android studio will fail run the following to set the environment variable for android studio:
82 //launchctl setenv ANDROID_NDK_HOME
83 //otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
84 task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
85     dependsOn 'buildNative'
86     from(new File('src/main/libs')) { include '**/*.so' exclude '**/libgnustl_shared.so' }
87     into new File(buildDir, 'native-libs')
88 }
89
90 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
91
92 clean.dependsOn 'cleanCopyNativeLibs'
93
94 tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
95     pkgTask ->
96     pkgTask.jniFolders = new HashSet<File>()
97     pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
98 }
99
100 task buildNative(type: Exec) {
101     if (System.env.ANDROID_NDK_HOME != null) {
102         //for windows use 'ndk-build.cmd'
103         //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
104         def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
105         commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE", '-C', file('src/main').absolutePath
106     } else {
107         println '##################'
108         println 'Skipping NDK build'
109         println 'Reason: ANDROID_NDK_HOME not set.'
110         println '##################'
111     }
112 }