Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 1 | import org.apache.tools.ant.taskdefs.condition.Os |
| 2 | |
| 3 | apply plugin: 'com.android.application' |
| 4 | |
| 5 | android { |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame] | 6 | compileSdkVersion 28 |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 7 | |
| 8 | defaultConfig { |
| 9 | applicationId "net.named_data.nfd" |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 10 | minSdkVersion 23 |
Alexander Afanasyev | 471bbff | 2019-03-09 11:35:04 -0800 | [diff] [blame] | 11 | targetSdkVersion 27 |
Alexander Afanasyev | a5beeed | 2019-03-19 16:27:18 -0400 | [diff] [blame^] | 12 | versionCode 4012 |
| 13 | versionName "0.6.5-3 (NFD 0.6.5)" |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 14 | multiDexEnabled true |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 15 | } |
Alexander Afanasyev | 0317742 | 2015-03-11 13:38:05 -0700 | [diff] [blame] | 16 | compileOptions { |
Alexander Afanasyev | 4a20a88 | 2017-12-07 17:44:07 -0500 | [diff] [blame] | 17 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 18 | targetCompatibility JavaVersion.VERSION_1_8 |
Alexander Afanasyev | 0317742 | 2015-03-11 13:38:05 -0700 | [diff] [blame] | 19 | } |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 20 | buildTypes { |
| 21 | release { |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 22 | minifyEnabled true |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 24 | } |
Alexander Afanasyev | 3d62ddd | 2015-02-12 16:59:52 -0800 | [diff] [blame] | 25 | debug { |
| 26 | debuggable true |
| 27 | jniDebuggable true |
| 28 | } |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 29 | } |
| 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 Afanasyev | 2a78ac6 | 2015-03-15 14:02:34 -0700 | [diff] [blame] | 40 | packagingOptions { |
| 41 | exclude 'META-INF/LICENSE.txt' |
| 42 | exclude 'META-INF/NOTICE.txt' |
| 43 | } |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 44 | lintOptions { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 45 | abortOnError false |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 46 | } |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 47 | |
| 48 | splits { |
| 49 | abi { |
| 50 | enable true // enable ABI split feature to create one APK per ABI |
Alexander Afanasyev | 0e16465 | 2017-12-07 17:32:05 -0500 | [diff] [blame] | 51 | reset() |
| 52 | include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" |
Alexander Afanasyev | bd74ad2 | 2016-01-06 18:09:10 -0800 | [diff] [blame] | 53 | universalApk false // don't generate an additional APK that targets all the ABIs |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
| 57 | // map for the version code |
| 58 | // versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-* |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 59 | project.ext.versionCodes = [//'armeabi': 1, // Deprecated in r16. Will be removed in r17. No hard float. |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 60 | 'armeabi-v7a': 2, |
| 61 | 'arm64-v8a': 3, |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 62 | // 'mips': 5, // Deprecated in r16. Will be removed in r17. Uses hard-float, and assumes a CPU:FPU clock ratio of 2:1 for maximum compatibility. Provides neither micromips nor MIPS16. |
| 63 | // 'mips64': 6, // Deprecated in r16. WIll be removed in r17 |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 64 | 'x86': 8, |
| 65 | 'x86_64': 9] |
| 66 | |
| 67 | android.applicationVariants.all { variant -> |
| 68 | // assign different version code for each output |
| 69 | variant.outputs.each { output -> |
| 70 | output.versionCodeOverride = project.ext.versionCodes.get( |
| 71 | output.getFilter( |
| 72 | com.android.build.OutputFile.ABI), 0) * 1000000 + |
| 73 | defaultConfig.versionCode |
| 74 | } |
| 75 | } |
| 76 | |
Alexander Afanasyev | 9388694 | 2016-02-09 16:00:24 -0800 | [diff] [blame] | 77 | task copyNdnCxxHeaders(type: Copy) { |
| 78 | from('src/main/jni/ndn-cxx/src') { |
| 79 | include '**/*.hpp' |
| 80 | } |
| 81 | into 'build/generated/source/include/ndn-cxx' |
| 82 | } |
| 83 | |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 84 | // call regular ndk-build(.cmd) script from app directory |
| 85 | task ndkBuild(type: Exec) { |
Alexander Afanasyev | 9388694 | 2016-02-09 16:00:24 -0800 | [diff] [blame] | 86 | dependsOn copyNdnCxxHeaders |
Alexander Afanasyev | 3d62ddd | 2015-02-12 16:59:52 -0800 | [diff] [blame] | 87 | def args = [getNdkBuildCmd(), '-C', file('src/main').absolutePath] |
| 88 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 89 | if (System.env.NDK_BUILD_PARALLEL != null) { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 90 | args.add("-j" + System.env.NDK_BUILD_PARALLEL) |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 91 | } |
Alexander Afanasyev | 3d62ddd | 2015-02-12 16:59:52 -0800 | [diff] [blame] | 92 | else { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 93 | args.add("-j" + Runtime.runtime.availableProcessors()) |
Alexander Afanasyev | 3d62ddd | 2015-02-12 16:59:52 -0800 | [diff] [blame] | 94 | } |
| 95 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 96 | if (System.env.NDK_BUILD_ABI != null) { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 97 | args.add("APP_ABI=" + System.env.NDK_BUILD_ABI) |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 98 | } |
Alexander Afanasyev | 3d62ddd | 2015-02-12 16:59:52 -0800 | [diff] [blame] | 99 | |
| 100 | if (System.env.NDK_DEBUG != null) { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 101 | args.add("V=1") |
Alexander Afanasyev | 3d62ddd | 2015-02-12 16:59:52 -0800 | [diff] [blame] | 102 | } |
| 103 | commandLine args |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | tasks.withType(JavaCompile) { |
| 107 | compileTask -> compileTask.dependsOn ndkBuild |
| 108 | } |
| 109 | |
| 110 | task cleanNative(type: Exec) { |
| 111 | commandLine getNdkBuildCmd(), '-C', file('src/main').absolutePath, 'clean' |
| 112 | } |
| 113 | |
| 114 | clean.dependsOn cleanNative |
| 115 | } |
| 116 | |
| 117 | def getNdkBuildCmd() { |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 118 | def ndk_build = getNdkDir() + "/ndk-build" |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 119 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { |
| 120 | ndk_build += ".cmd" |
| 121 | } |
| 122 | |
| 123 | return ndk_build |
| 124 | } |
| 125 | |
Alexander Afanasyev | bd74ad2 | 2016-01-06 18:09:10 -0800 | [diff] [blame] | 126 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 127 | def getNdkDir() { |
| 128 | if (System.env.ANDROID_NDK_ROOT != null) |
| 129 | return System.env.ANDROID_NDK_ROOT |
| 130 | |
| 131 | Properties properties = new Properties() |
| 132 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) |
Alexander Afanasyev | bd74ad2 | 2016-01-06 18:09:10 -0800 | [diff] [blame] | 133 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 134 | def ndk_dir = properties.getProperty('ndk.dir', null) |
| 135 | if (ndk_dir == null) { |
| 136 | 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.") |
| 137 | } |
| 138 | return ndk_dir |
| 139 | } |
| 140 | |
Alexander Afanasyev | 0317742 | 2015-03-11 13:38:05 -0700 | [diff] [blame] | 141 | repositories { |
| 142 | mavenLocal() |
| 143 | mavenCentral() |
Alexander Afanasyev | 0a15b6d | 2016-01-31 12:13:28 -0800 | [diff] [blame] | 144 | maven { |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame] | 145 | url "https://oss.sonatype.org/content/repositories/releases/" |
Alexander Afanasyev | 0a15b6d | 2016-01-31 12:13:28 -0800 | [diff] [blame] | 146 | } |
Alexander Afanasyev | 0317742 | 2015-03-11 13:38:05 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 149 | dependencies { |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 150 | implementation fileTree(dir: 'libs', include: ['*.jar']) |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 151 | implementation('com.google.android.material:material:1.1.0-alpha04') { |
| 152 | exclude group: 'com.google.guava', module: 'listenablefuture' |
| 153 | } |
| 154 | implementation('androidx.appcompat:appcompat:1.0.2') { |
| 155 | exclude group: 'com.google.guava', module: 'listenablefuture' |
| 156 | } |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame] | 157 | implementation 'com.android.volley:volley:1.1.1' |
Alexander Afanasyev | 0317742 | 2015-03-11 13:38:05 -0700 | [diff] [blame] | 158 | |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame] | 159 | implementation('net.named-data.jndn-extra:jndn-management:1.2.0') { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 160 | exclude group: 'net.named-data', module: 'jndn' |
Alexander Afanasyev | 0a15b6d | 2016-01-31 12:13:28 -0800 | [diff] [blame] | 161 | } |
Alexander Afanasyev | 63e81f9 | 2019-02-05 13:30:26 -0500 | [diff] [blame] | 162 | implementation('net.named-data:jndn-android:0.20') { |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 163 | exclude group: 'org.xerial' |
| 164 | exclude group: 'com.google.android' |
Alexander Afanasyev | f7b6236 | 2015-09-10 23:29:47 -0700 | [diff] [blame] | 165 | } |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame] | 166 | implementation 'net.named-data.jndn-extra:jndn-xx-util:0.0.2' |
| 167 | implementation 'joda-time:joda-time:2.10' |
Alexander Afanasyev | ddaa831 | 2015-01-27 16:33:45 -0800 | [diff] [blame] | 168 | } |
Alexander Afanasyev | bd74ad2 | 2016-01-06 18:09:10 -0800 | [diff] [blame] | 169 | |
| 170 | Properties properties = new Properties() |
| 171 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) |
| 172 | |
| 173 | if (properties['keystore'] == null || properties['keystore.password'] == null || |
Alexander Afanasyev | 5005fc5 | 2019-03-09 17:50:15 -0800 | [diff] [blame] | 174 | properties['keystore.key.alias'] == null || properties['keystore.key.password'] == null) { |
Alexander Afanasyev | bd74ad2 | 2016-01-06 18:09:10 -0800 | [diff] [blame] | 175 | println("Cannot sign .apk: specify keystore, keystore.password, keystore.key.alias, and keystore.key.password in local.properties.") |
| 176 | } |
| 177 | else { |
| 178 | android { |
| 179 | signingConfigs { |
| 180 | release { |
| 181 | storeFile file(properties['keystore']) |
| 182 | storePassword properties['keystore.password'] |
| 183 | keyAlias properties['keystore.key.alias'] |
| 184 | keyPassword properties['keystore.key.password'] |
| 185 | } |
| 186 | } |
| 187 | buildTypes { |
| 188 | release { |
| 189 | signingConfig signingConfigs.release |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if (properties['google-play'] != null) { |
Alexander Afanasyev | 0e16465 | 2017-12-07 17:32:05 -0500 | [diff] [blame] | 196 | // apply plugin: 'net.named-data.playground.play' |
| 197 | apply plugin: 'com.github.triplet.play' |
Alexander Afanasyev | bd74ad2 | 2016-01-06 18:09:10 -0800 | [diff] [blame] | 198 | |
| 199 | play { |
| 200 | track = 'alpha' |
| 201 | jsonFile = file(properties['google-play']) |
| 202 | } |
| 203 | } |