blob: 8214644705564c41adcd6278f9b158f2481db84a [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 }
40
41 splits {
42 abi {
43 enable true // enable ABI split feature to create one APK per ABI
44 universalApk true //generate an additional APK that targets all the ABIs
45 }
46 }
47
48 // map for the version code
49 // versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
50 project.ext.versionCodes = ['armeabi': 1,
51 'armeabi-v7a': 2,
52 'arm64-v8a': 3,
53 'mips': 5,
54 'mips64': 6,
55 'x86': 8,
56 'x86_64': 9]
57
58 android.applicationVariants.all { variant ->
59 // assign different version code for each output
60 variant.outputs.each { output ->
61 output.versionCodeOverride = project.ext.versionCodes.get(
62 output.getFilter(
63 com.android.build.OutputFile.ABI), 0) * 1000000 +
64 defaultConfig.versionCode
65 }
66 }
67
68 // call regular ndk-build(.cmd) script from app directory
69 task ndkBuild(type: Exec) {
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080070 def args = [getNdkBuildCmd(), '-C', file('src/main').absolutePath]
71
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080072 if (System.env.NDK_BUILD_PARALLEL != null) {
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080073 args.add("-j" + System.env.NDK_BUILD_PARALLEL)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080074 }
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080075 else {
76 args.add("-j" + Runtime.runtime.availableProcessors())
77 }
78
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080079 if (System.env.NDK_BUILD_ABI != null) {
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080080 args.add("APP_ABI=" + System.env.NDK_BUILD_ABI)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080081 }
Alexander Afanasyev3d62ddd2015-02-12 16:59:52 -080082
83 if (System.env.NDK_DEBUG != null) {
84 args.add("NDK_DEBUG=1")
85 }
86 commandLine args
Alexander Afanasyevddaa8312015-01-27 16:33:45 -080087 }
88
89 tasks.withType(JavaCompile) {
90 compileTask -> compileTask.dependsOn ndkBuild
91 }
92
93 task cleanNative(type: Exec) {
94 commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath, 'clean'
95 }
96
97 clean.dependsOn cleanNative
98}
99
100def getNdkBuildCmd() {
Alexander Afanasyev087c7c12015-02-02 00:21:21 -0800101 def ndk_build = getNdkDir() + "/ndk-build"
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800102 if (Os.isFamily(Os.FAMILY_WINDOWS)) {
103 ndk_build += ".cmd"
104 }
105
106 return ndk_build
107}
108
Alexander Afanasyev087c7c12015-02-02 00:21:21 -0800109def getNdkDir() {
110 if (System.env.ANDROID_NDK_ROOT != null)
111 return System.env.ANDROID_NDK_ROOT
112
113 Properties properties = new Properties()
114 properties.load(project.rootProject.file('local.properties').newDataInputStream())
115 def ndk_dir = properties.getProperty('ndk.dir', null)
116 if (ndk_dir == null) {
117 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.")
118 }
119 return ndk_dir
120}
121
Alexander Afanasyev03177422015-03-11 13:38:05 -0700122repositories {
123 mavenLocal()
124 mavenCentral()
125}
126
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800127dependencies {
128 compile fileTree(dir: 'libs', include: ['*.jar'])
Ivan Yeo432488f2015-02-02 19:35:23 -0800129 compile 'com.android.support:appcompat-v7:20.0.0'
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800130 compile 'com.android.support:support-v4:21.0.3'
Alexander Afanasyev03177422015-03-11 13:38:05 -0700131
132 compile 'net.named-data:jndn:0.4'
133 compile 'net.named-data.jndn-xx:jndn-xx-util:0.0.1'
134
135 compile 'com.intel.jndn.utils:jndn-utils:0.9.5'
136 compile 'com.intel.jndn.management:jndn-management:0.9.5'
137 compile 'com.google.protobuf:protobuf-java:2.6.1'
138
139 compile 'joda-time:joda-time:2.7'
Alexander Afanasyevddaa8312015-01-27 16:33:45 -0800140}