blob: 674060e3b25fb7a5d0e3060773c5b87f9ed229e6 [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 }
Alexander Afanasyev03177422015-03-11 13:38:05 -070016 compileOptions {
17 sourceCompatibility JavaVersion.VERSION_1_7
18 targetCompatibility JavaVersion.VERSION_1_7
19 }
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080020 buildTypes {
21 release {
22 minifyEnabled false
23 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 }
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080025 debug {
26 debuggable true
27 jniDebuggable true
28 }
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080029 }
30 sourceSets {
31 main {
32 java.srcDirs "src/main/java"
33 res.srcDirs "src/main/res"
34 jniLibs.srcDir 'src/main/libs'
35 jni.srcDirs = [] //disable automatic ndk-build call
36 }
37 androidTest.setRoot('tests')
38 androidTest.java.srcDirs = ['tests/src']
39 }
Alexander Afanasyev2a78ac62015-03-15 14:02:34 -070040 packagingOptions {
41 exclude 'META-INF/LICENSE.txt'
42 exclude 'META-INF/NOTICE.txt'
43 }
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080044
45 splits {
46 abi {
47 enable true // enable ABI split feature to create one APK per ABI
48 universalApk true //generate an additional APK that targets all the ABIs
49 }
50 }
51
52 // map for the version code
53 // versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
54 project.ext.versionCodes = ['armeabi': 1,
55 'armeabi-v7a': 2,
56 'arm64-v8a': 3,
57 'mips': 5,
58 'mips64': 6,
59 'x86': 8,
60 'x86_64': 9]
61
62 android.applicationVariants.all { variant ->
63 // assign different version code for each output
64 variant.outputs.each { output ->
65 output.versionCodeOverride = project.ext.versionCodes.get(
66 output.getFilter(
67 com.android.build.OutputFile.ABI), 0) * 1000000 +
68 defaultConfig.versionCode
69 }
70 }
71
72 // call regular ndk-build(.cmd) script from app directory
73 task ndkBuild(type: Exec) {
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080074 def args = [getNdkBuildCmd(), '-C', file('src/main').absolutePath]
75
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080076 if (System.env.NDK_BUILD_PARALLEL != null) {
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080077 args.add("-j" + System.env.NDK_BUILD_PARALLEL)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080078 }
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080079 else {
80 args.add("-j" + Runtime.runtime.availableProcessors())
81 }
82
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080083 if (System.env.NDK_BUILD_ABI != null) {
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080084 args.add("APP_ABI=" + System.env.NDK_BUILD_ABI)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080085 }
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080086
87 if (System.env.NDK_DEBUG != null) {
88 args.add("NDK_DEBUG=1")
89 }
90 commandLine args
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080091 }
92
93 tasks.withType(JavaCompile) {
94 compileTask -> compileTask.dependsOn ndkBuild
95 }
96
97 task cleanNative(type: Exec) {
98 commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath, 'clean'
99 }
100
101 clean.dependsOn cleanNative
102}
103
104def getNdkBuildCmd() {
Alexander Afanasyev087c7c12015-02-02 00:21:21 -0800105 def ndk_build = getNdkDir() + "/ndk-build"
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800106 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
107 ndk_build += ".cmd"
108 }
109
110 return ndk_build
111}
112
Alexander Afanasyev087c7c12015-02-02 00:21:21 -0800113def getNdkDir() {
114 if (System.env.ANDROID_NDK_ROOT != null)
115 return System.env.ANDROID_NDK_ROOT
116
117 Properties properties = new Properties()
118 properties.load(project.rootProject.file('local.properties').newDataInputStream())
119 def ndk_dir = properties.getProperty('ndk.dir', null)
120 if (ndk_dir == null) {
121 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.")
122 }
123 return ndk_dir
124}
125
Alexander Afanasyev03177422015-03-11 13:38:05 -0700126repositories {
127 mavenLocal()
128 mavenCentral()
129}
130
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800131dependencies {
132 compile fileTree(dir: 'libs', include: ['*.jar'])
Ivan Yeo432488f2015-02-02 19:35:23 -0800133 compile 'com.android.support:appcompat-v7:20.0.0'
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800134 compile 'com.android.support:support-v4:21.0.3'
Alexander Afanasyev03177422015-03-11 13:38:05 -0700135
136 compile 'net.named-data:jndn:0.4'
137 compile 'net.named-data.jndn-xx:jndn-xx-util:0.0.1'
138
139 compile 'com.intel.jndn.utils:jndn-utils:0.9.5'
140 compile 'com.intel.jndn.management:jndn-management:0.9.5'
141 compile 'com.google.protobuf:protobuf-java:2.6.1'
142
143 compile 'joda-time:joda-time:2.7'
Alexander Afanasyev2a78ac62015-03-15 14:02:34 -0700144 compile 'commons-lang:commons-lang:2.6'
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800145}