2 * //******************************************************************
\r
4 * // Copyright 2015 Intel Corporation.
\r
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
8 * // Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * // you may not use this file except in compliance with the License.
\r
10 * // You may obtain a copy of the License at
\r
12 * // http://www.apache.org/licenses/LICENSE-2.0
\r
14 * // Unless required by applicable law or agreed to in writing, software
\r
15 * // distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * // See the License for the specific language governing permissions and
\r
18 * // limitations under the License.
\r
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
23 apply plugin: 'com.android.library'
\r
26 compileSdkVersion 21
\r
27 buildToolsVersion "20.0.0"
\r
28 archivesBaseName = "iotivity"
\r
30 libraryVariants.all { variant ->
\r
31 variant.outputs.each { output ->
\r
32 def outputFile = output.outputFile
\r
33 if (outputFile != null && outputFile.name.endsWith('.aar')) {
\r
34 def fileName = "${archivesBaseName}-${TARGET_ARCH}-${outputFile.name}"
\r
35 output.outputFile = new File(outputFile.parent, fileName)
\r
48 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
\r
58 manifest.srcFile 'src/main/AndroidManifest.xml'
\r
59 jniLibs.srcDir 'libs'
\r
60 jni.srcDirs = [] //disable automatic ndk-build call
\r
67 compile fileTree(dir: 'libs', include: ['*.jar'])
\r
73 //If using this, Android studio will fail run the following to set the environment variable for android studio:
\r
74 //launchctl setenv ANDROID_NDK_HOME /Users/boos_patrick/Development/Android/android-ndk-r8e
\r
75 //otherwise remove the dependsOn part and run ./gradlew buildNative from the command line
\r
77 task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
\r
78 dependsOn 'buildNative'
\r
79 from(new File('libs')) { include '**/*.so' }
\r
80 into new File(buildDir, 'native-libs')
\r
83 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
\r
85 clean.dependsOn 'cleanCopyNativeLibs'
\r
87 tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
\r
88 pkgTask.jniFolders = new HashSet<File>()
\r
89 pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
\r
92 task buildNative(type: Exec) {
\r
93 if (System.env.ANDROID_NDK_HOME != null) {
\r
94 //for windows use 'ndk-build.cmd'
\r
95 //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
\r
96 def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
\r
97 commandLine ndkBuild, "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE", "SECURE=$SECURED"
99 println '##################'
\r
100 println 'Skipping NDK build'
\r
101 println 'Reason: ANDROID_NDK_HOME not set.'
\r
102 println '##################'
\r
106 //task (copyARR, type: Copy) {
\r
108 // from 'build/outputs/aar/'
\r
109 // into '../../../out/android/'
\r
110 // include '**/*.aar'
\r
113 //build.finalizedBy(copyARR)
\r