|
| 1 | +//////////////////////////////////////////////////////////////////////////////// |
| 2 | +// |
| 3 | +// PLUGIN_VERSION is the common version name when describing the plugin. |
| 4 | +// ATAK_VERSION is for the version of ATAK this plugin should be compatible |
| 5 | +// with some examples include 3.11.0, 3.11.0.civ 3.11.1.fvey |
| 6 | +// |
| 7 | +//////////////////////////////////////////////////////////////////////////////// |
| 8 | + |
| 9 | +buildscript { |
| 10 | + |
| 11 | + ext.PLUGIN_VERSION = "1.0" |
| 12 | + ext.ATAK_VERSION = "4.8.1" |
| 13 | + |
| 14 | + def takdevVersion = '2.+' |
| 15 | + |
| 16 | + ext.getValueFromPropertiesFile = { propFile, key -> |
| 17 | + if(!propFile.isFile() || !propFile.canRead()) |
| 18 | + return null |
| 19 | + def prop = new Properties() |
| 20 | + def reader = propFile.newReader() |
| 21 | + try { |
| 22 | + prop.load(reader) |
| 23 | + } finally { |
| 24 | + reader.close() |
| 25 | + } |
| 26 | + return prop.get(key) |
| 27 | + } |
| 28 | + |
| 29 | + def getProperty = { name, defValue -> |
| 30 | + def prop = project.properties[name] ?: |
| 31 | + getValueFromPropertiesFile(project.rootProject.file('local.properties'), name) |
| 32 | + return (null == prop) ? defValue : prop |
| 33 | + } |
| 34 | + |
| 35 | + def urlKey = 'takrepo.url' |
| 36 | + |
| 37 | + ext.isDevKitEnabled = { -> |
| 38 | + return getProperty(urlKey, null) != null |
| 39 | + } |
| 40 | + |
| 41 | + ext.takrepoUrl = getProperty(urlKey, 'http://localhost/') |
| 42 | + ext.takrepoUser = getProperty('takrepo.user', 'invalid') |
| 43 | + ext.takrepoPassword = getProperty('takrepo.password', 'invalid') |
| 44 | + ext.takdevPlugin = getProperty('takdev.plugin', "${rootDir}/../../atak-gradle-takdev.jar") |
| 45 | + |
| 46 | + repositories { |
| 47 | + google() |
| 48 | + mavenCentral() |
| 49 | + mavenLocal() |
| 50 | + maven { |
| 51 | + url "https://jitpack.io" |
| 52 | + } |
| 53 | + maven { |
| 54 | + url = takrepoUrl |
| 55 | + credentials { |
| 56 | + username = takrepoUser |
| 57 | + password = takrepoPassword |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + dependencies { |
| 62 | + classpath 'com.android.tools.build:gradle:4.0.2' |
| 63 | + if(isDevKitEnabled()) { |
| 64 | + classpath "com.atakmap.gradle:atak-gradle-takdev:${takdevVersion}" |
| 65 | + } else { |
| 66 | + classpath files(takdevPlugin) |
| 67 | + } |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +allprojects { |
| 72 | + repositories { |
| 73 | + mavenCentral() |
| 74 | + google() |
| 75 | + mavenCentral() |
| 76 | + mavenLocal() |
| 77 | + maven { |
| 78 | + url "https://jitpack.io" |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +apply plugin: 'com.android.application' |
| 84 | +apply plugin: 'atak-takdev-plugin' |
| 85 | + |
| 86 | +// Attempt to get a suitable version name for the plugin based on |
| 87 | +// either a git or svn repository |
| 88 | +def getVersionName() { |
| 89 | + try { |
| 90 | + def stdout = new ByteArrayOutputStream() |
| 91 | + exec { |
| 92 | + commandLine 'git', 'rev-parse', '--short=8', 'HEAD' |
| 93 | + standardOutput = stdout |
| 94 | + } |
| 95 | + def describe = stdout.toString().trim() |
| 96 | + println("versionName[git]: $describe") |
| 97 | + return describe |
| 98 | + } catch (Exception ignored) { |
| 99 | + println("error occured, using revision of 1") |
| 100 | + return 1 |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | + |
| 105 | +// Attempt to get a suitable version code for the plugin based on |
| 106 | +// either a git or svn repository |
| 107 | +def getVersionCode() { |
| 108 | + try { |
| 109 | + new ByteArrayOutputStream().withStream { os -> |
| 110 | + def result = exec { |
| 111 | + executable = 'git' |
| 112 | + args = ['show', '-s', '--format=%ct'] |
| 113 | + standardOutput = os |
| 114 | + ignoreExitValue = true |
| 115 | + } |
| 116 | + |
| 117 | + def outputAsString = os.toString() |
| 118 | + ext.revision = "$outputAsString".toInteger() |
| 119 | + |
| 120 | + println("version[git]: $revision") |
| 121 | + } |
| 122 | + } catch (Exception ignored) { |
| 123 | + println("error occured, using revision of 1") |
| 124 | + ext.revision = 1 |
| 125 | + } |
| 126 | + |
| 127 | + return revision |
| 128 | +} |
| 129 | + |
| 130 | + |
| 131 | +android { |
| 132 | + compileSdkVersion 26 |
| 133 | + buildToolsVersion "29.0.2" |
| 134 | + |
| 135 | + dexOptions { |
| 136 | + jumboMode = true |
| 137 | + } |
| 138 | + |
| 139 | + lintOptions { |
| 140 | + checkReleaseBuilds true |
| 141 | + // Or, if you prefer, you can continue to check for errors in release builds, |
| 142 | + // but continue the build even when errors are found: |
| 143 | + abortOnError true |
| 144 | + } |
| 145 | + |
| 146 | + signingConfigs { |
| 147 | + debug { |
| 148 | + def kf = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takDebugKeyFile') |
| 149 | + def kfp = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takDebugKeyFilePassword') |
| 150 | + def ka = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takDebugKeyAlias') |
| 151 | + def kp = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takDebugKeyPassword') |
| 152 | + |
| 153 | + if (kf == null) { |
| 154 | + throw new GradleException("No signing key configured!") |
| 155 | + } |
| 156 | + |
| 157 | + storeFile file(kf) |
| 158 | + if (kfp != null) storePassword kfp |
| 159 | + if (ka != null) keyAlias ka |
| 160 | + if (kp != null) keyPassword kp |
| 161 | + } |
| 162 | + release { |
| 163 | + def kf = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takReleaseKeyFile') |
| 164 | + def kfp = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takReleaseKeyFilePassword') |
| 165 | + def ka = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takReleaseKeyAlias') |
| 166 | + def kp = getValueFromPropertiesFile(project.rootProject.file('local.properties'), 'takReleaseKeyPassword') |
| 167 | + |
| 168 | + if (kf == null) { |
| 169 | + throw new GradleException("No signing key configured!") |
| 170 | + } |
| 171 | + |
| 172 | + storeFile file(kf) |
| 173 | + if (kfp != null) storePassword kfp |
| 174 | + if (ka != null) keyAlias ka |
| 175 | + if (kp != null) keyPassword kp |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + buildTypes { |
| 180 | + debug { |
| 181 | + debuggable true |
| 182 | + matchingFallbacks = ['sdk'] |
| 183 | + } |
| 184 | + |
| 185 | + release { |
| 186 | + minifyEnabled true |
| 187 | + proguardFile 'proguard-gradle.txt' |
| 188 | + signingConfig signingConfigs.release |
| 189 | + matchingFallbacks = ['odk'] |
| 190 | + } |
| 191 | + } |
| 192 | + |
| 193 | + flavorDimensions "application" |
| 194 | + |
| 195 | + productFlavors { |
| 196 | + mil { |
| 197 | + getIsDefault().set(true) |
| 198 | + dimension "application" |
| 199 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".MIL"] |
| 200 | + } |
| 201 | + civ { |
| 202 | + dimension "application" |
| 203 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".CIV"] |
| 204 | + } |
| 205 | + aus { |
| 206 | + dimension "application" |
| 207 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".AUS"] |
| 208 | + } |
| 209 | + nzl { |
| 210 | + dimension "application" |
| 211 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".NZL"] |
| 212 | + } |
| 213 | + prt { |
| 214 | + dimension "application" |
| 215 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".PRT"] |
| 216 | + } |
| 217 | + nor { |
| 218 | + dimension "application" |
| 219 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".NOR"] |
| 220 | + } |
| 221 | + hun { |
| 222 | + dimension "application" |
| 223 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".HUN"] |
| 224 | + } |
| 225 | + bel { |
| 226 | + dimension "application" |
| 227 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".BEL"] |
| 228 | + } |
| 229 | + swe { |
| 230 | + dimension "application" |
| 231 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".SWE"] |
| 232 | + } |
| 233 | + natosof { |
| 234 | + dimension "application" |
| 235 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".NATOSOF"] |
| 236 | + } |
| 237 | + gbr { |
| 238 | + dimension "application" |
| 239 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".GBR"] |
| 240 | + } |
| 241 | + gov { |
| 242 | + dimension "application" |
| 243 | + // GOV builds are just CIV api builds with additional information in the strings file |
| 244 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".CIV"] |
| 245 | + } |
| 246 | + can { |
| 247 | + dimension "application" |
| 248 | + manifestPlaceholders = [atakApiVersion: "com.atakmap.app@" + ATAK_VERSION + ".CAN"] |
| 249 | + } |
| 250 | + } |
| 251 | + |
| 252 | + packagingOptions { |
| 253 | + exclude 'META-INF/INDEX.LIST' |
| 254 | + } |
| 255 | + |
| 256 | + sourceSets { |
| 257 | + main { |
| 258 | + |
| 259 | + // It is strongly encouraged that plugin developers do not modify the archiveBaseName, version code logic and version |
| 260 | + // name logic to provide for consistency within the community. |
| 261 | + setProperty("archivesBaseName", "ATAK-Plugin-" + rootProject.name + "-" + PLUGIN_VERSION + "-" + getVersionName() + "-" + ATAK_VERSION) |
| 262 | + defaultConfig.versionCode = getVersionCode() |
| 263 | + defaultConfig.versionName = PLUGIN_VERSION + " (" + getVersionName() + ") - [" + ATAK_VERSION + "]" |
| 264 | + } |
| 265 | + |
| 266 | + gov.java.srcDirs 'src/gov/java' |
| 267 | + gov.assets.srcDir 'src/gov/assets' |
| 268 | + gov.res.srcDir 'src/gov/res' |
| 269 | + |
| 270 | + // Move the build types to build-types/<type> |
| 271 | + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... |
| 272 | + // This moves them out of them default location under src/<type>/... which would |
| 273 | + // conflict with src/ being used by the main source set. |
| 274 | + // Adding new build types or product flavors should be accompanied |
| 275 | + // by a similar customization. |
| 276 | + debug.setRoot('build-types/debug') |
| 277 | + release.setRoot('build-types/release') |
| 278 | + |
| 279 | + } |
| 280 | + |
| 281 | + defaultConfig { |
| 282 | + minSdkVersion 21 |
| 283 | + ndk { |
| 284 | + abiFilters "armeabi-v7a", "arm64-v8a", "x86" |
| 285 | + } |
| 286 | + } |
| 287 | +} |
| 288 | + |
| 289 | + |
| 290 | +dependencies { |
| 291 | + implementation fileTree(dir: 'libs', include: '*.jar') |
| 292 | + implementation 'com.paulmandal.atak:libcotshrink:1.0.2' |
| 293 | + //implementation 'com.google.protobuf:protobuf-lite:3.0.1' |
| 294 | +} |
0 commit comments