blob: 9acf98efe4946dc96f1b35908082f0230d363c17 [file] [log] [blame]
Alexander Afanasyevddaa8312015-01-27 16:33:45 -08001import org.apache.tools.ant.taskdefs.condition.Os
2
3apply plugin: 'com.android.application'
4
5android {
Ivan Yeo432488f2015-02-02 19:35:23 -08006 compileSdkVersion 19
Alexander Afanasyevddaa8312015-01-27 16:33:45 -08007 buildToolsVersion "21.1.2"
8
9 defaultConfig {
10 applicationId "net.named_data.nfd"
Ivan Yeo432488f2015-02-02 19:35:23 -080011 minSdkVersion 15
12 targetSdkVersion 19
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080013 versionCode 2001
14 versionName "0.2.1"
15 }
16 buildTypes {
17 release {
18 minifyEnabled false
19 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 }
21 }
22 sourceSets {
23 main {
24 java.srcDirs "src/main/java"
25 res.srcDirs "src/main/res"
26 jniLibs.srcDir 'src/main/libs'
27 jni.srcDirs = [] //disable automatic ndk-build call
28 }
29 androidTest.setRoot('tests')
30 androidTest.java.srcDirs = ['tests/src']
31 }
32
33 splits {
34 abi {
35 enable true // enable ABI split feature to create one APK per ABI
36 universalApk true //generate an additional APK that targets all the ABIs
37 }
38 }
39
40 // map for the version code
41 // versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
42 project.ext.versionCodes = ['armeabi': 1,
43 'armeabi-v7a': 2,
44 'arm64-v8a': 3,
45 'mips': 5,
46 'mips64': 6,
47 'x86': 8,
48 'x86_64': 9]
49
50 android.applicationVariants.all { variant ->
51 // assign different version code for each output
52 variant.outputs.each { output ->
53 output.versionCodeOverride = project.ext.versionCodes.get(
54 output.getFilter(
55 com.android.build.OutputFile.ABI), 0) * 1000000 +
56 defaultConfig.versionCode
57 }
58 }
59
60 // call regular ndk-build(.cmd) script from app directory
61 task ndkBuild(type: Exec) {
62 commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath
63 }
64
65 tasks.withType(JavaCompile) {
66 compileTask -> compileTask.dependsOn ndkBuild
67 }
68
69 task cleanNative(type: Exec) {
70 commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath, 'clean'
71 }
72
73 clean.dependsOn cleanNative
74}
75
76def getNdkBuildCmd() {
77 if (System.env.ANDROID_NDK_ROOT != null)
78 return System.env.ANDROID_NDK_ROOT
79
80 Properties properties = new Properties()
81 properties.load(project.rootProject.file('local.properties').newDataInputStream())
82 String ndk_dir = properties.getProperty('ndk.dir', null)
83 if (ndk_dir == null) {
84 throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")
85 }
86
87 String ndk_build = ndk_dir + "/ndk-build"
88 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
89 ndk_build += ".cmd"
90 }
91
92 return ndk_build
93}
94
95dependencies {
96 compile fileTree(dir: 'libs', include: ['*.jar'])
Ivan Yeo432488f2015-02-02 19:35:23 -080097 compile 'com.android.support:appcompat-v7:20.0.0'
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080098 compile 'com.android.support:support-v4:21.0.3'
99}