apply plugin: 'com.android.application' apply plugin: 'com.github.ksoichiro.eclipse.aar' // Global Parameters accepted // TARGET_APP_NAME - app name // APK_NUMBER_VERSION - version number of apk // APK_VERSION_SUFFIX - build number like #99999Z, appended (for dev builds) to Manifest's versionName as X.X.X#99999Z // Z means flavor: M=-master, D=-main-default, B=-Blackberry, Des=-design, MQA=-main-qt-arm, MQDA=-main-qt-default-arm, S=-sherpafy // APP_EDITION - date stamp of builds // APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon // 1. To be done Filter fonts // // // // // // // Less important // Configure eclipse-aar plugin def analytics = (!System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+play_market")) && getGradle().getStartParameter().getTaskRequests().toString().contains("Free") eclipseAar { // See "Configurations" for details androidTarget = 'android-27' aarDependenciesDir = 'aarDependencies' } android { compileSdkVersion 27 buildToolsVersion "27.0.3" signingConfigs { development { storeFile file("../keystores/debug.keystore") storePassword "android" keyAlias "androiddebugkey" keyPassword "android" } publishing { storeFile file("/var/lib/jenkins/osmand_key") storePassword System.getenv("OSMAND_APK_PASSWORD") keyAlias "osmand" keyPassword System.getenv("OSMAND_APK_PASSWORD") } } defaultConfig { minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 targetSdkVersion 23 versionCode 300 versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode multiDexEnabled true versionName "3.0.0" versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName versionName System.getenv("APK_VERSION_SUFFIX")? versionName + System.getenv("APK_VERSION_SUFFIX").toString(): versionName } lintOptions { lintConfig file("lint.xml") abortOnError false warningsAsErrors false } // This is from OsmAndCore_android.aar - for some reason it's not inherited aaptOptions { // Don't compress any embedded resources noCompress "qz" cruncherEnabled = false } dexOptions { incremental true javaMaxHeapSize "4g" } sourceSets { main { manifest.srcFile "AndroidManifest.xml" jni.srcDirs = [] jniLibs.srcDirs = ["libs"] aidl.srcDirs = ["src"] java.srcDirs = ["src"] resources.srcDirs = ["src"] renderscript.srcDirs = ["src"] res.srcDirs = ["res"] assets.srcDirs = ["assets"] } free { manifest.srcFile "AndroidManifest-free.xml" } freedev { manifest.srcFile "AndroidManifest-freedev.xml" } freecustom { manifest.srcFile "AndroidManifest-freecustom.xml" } legacy { jniLibs.srcDirs = ["libgnustl"] } } flavorDimensions "version", "coreversion", "abi" productFlavors { // ABI armv7 { dimension "abi" ndk { abiFilter "armeabi-v7a" } } armv5 { dimension "abi" ndk { abiFilter "armeabi" } } x86 { dimension "abi" ndk { abiFilter "x86" } } mips { dimension "abi" ndk { abiFilter "mips" } } fat { dimension "abi" } // Version freedev { dimension "version" applicationId "net.osmand.dev" // resConfig "en" } free { dimension "version" applicationId "net.osmand" } freeres { dimension "version" applicationId "net.osmand" resConfig "en" } freecustom { dimension "version" applicationId "net.osmand.freecustom" } full { dimension "version" applicationId "net.osmand.plus" } fulldev { dimension "version" applicationId "net.osmand.plus" resConfig "en" //resConfigs "xxhdpi", "nodpi" } // CoreVersion legacy { dimension "coreversion" } qtcore { dimension "coreversion" } qtcoredebug { dimension "coreversion" } } buildTypes { debug { // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' // minifyEnabled true // proguardFiles 'proguard-project.txt' signingConfig signingConfigs.development } release { // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' // minifyEnabled true //proguardFiles 'proguard-project.txt' signingConfig signingConfigs.publishing } } } def replaceNoTranslate(line) { if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) { return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") } if (line.contains("\"app_name_free\"") && System.getenv("TARGET_APP_NAME")) { return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") } if (line.contains("\"app_edition\"") && System.getenv("APP_EDITION")) { return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<") } if (line.contains("\"versionFeatures\"") && System.getenv("APP_FEATURES")) { return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_FEATURES") + "<") } return line; } task updateNoTranslate(type: Copy) { from('.') { include 'no_translate.xml' filter { line -> replaceNoTranslate(line); } } into 'res/values/' } task validateTranslate { println "Validating translations" file("res").eachFileRecurse groovy.io.FileType.FILES, { if (it.name == "strings.xml" || it.name == "phrases.xml") { it.eachLine { line -> if (line.contains("\$ s") || line.contains("\$ d") || line.contains("\$ f") || line.contains(" \$s") || line.contains(" \$d") || line.contains(" \$f") || line.contains("1\$ ") || line.contains("2\$ ") || line.contains("3\$ ") || (line.contains("% \$") || line.contains("% 1") || line.contains("% 2") || line.contains("% 3"))) { throw new GradleException("Incorrect translation " + it.getAbsolutePath() + " " + line); } } } } } task collectVoiceAssets(type: Sync) { from "../../resources/voice" into "assets/voice" include "**/*.p" } task cleanNoTranslate(type: Delete) { delete('res/values/no_translate.xml') } task collectFonts(type: Copy) { from "../../resources/fonts" from "../../resources/rendering_styles/fonts" // from "../../resources/rendering_styles/fonts/OpenSans" into "assets/fonts" include "*.ttf" } task collectHelpContentsStyle(type: Copy) { from("../../help/website/help/") { include "style.css" } into "assets" } task collectHelpContentsAssets(type: Copy) { from("../../help/website/help") { include "about.html" include "changes.html" include "faq.html" include "technical-articles.html" include "map-legend.html" } from("../../help/website/feature_articles") { include "*.html" } into "assets/feature_articles" } task collectRoutingResources(type: Sync) { from "../../resources/routing" into "src/net/osmand/router" include "*.xml" } task collectMiscResources(type: Copy) { into "src/net/osmand/osm" from("../../resources/obf_creation") { include "rendering_types.xml" } from("../../resources/poi") { include "poi_types.xml" } } task collectRenderingStylesResources(type: Sync) { from "../../resources/rendering_styles" into "src/net/osmand/render" include "*.xml" } task collectRegionsInfoResources(type: Copy) { from "../../resources/countries-info" into "src/net/osmand/map" include "regions.ocbf" } task copyStyleIcons(type: Copy) { from "../../resources/rendering_styles/style-icons/" into "res/" include "**/*.png" } task collectExternalResources { dependsOn collectVoiceAssets, collectFonts, collectHelpContentsAssets, collectHelpContentsStyle, collectRoutingResources, collectRenderingStylesResources, collectRegionsInfoResources, collectMiscResources, copyStyleIcons, updateNoTranslate, validateTranslate } // Legacy core build import org.apache.tools.ant.taskdefs.condition.Os task buildOsmAndCore(type: Exec) { description "Build Legacy OsmAndCore" if (!Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine "bash", file("./old-ndk-build.sh").getAbsolutePath() } else { commandLine "cmd", "/c", "echo", "Not supported" } } task cleanupDuplicatesInCore() { dependsOn buildOsmAndCore // doesn't work for legacy debug builds doLast { file("libgnustl/armeabi").mkdirs() file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so")) file("libgnustl/armeabi-v7a").mkdirs() file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so")) file("libgnustl/mips").mkdirs() file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so")) file("libgnustl/x86").mkdirs() file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so")) } } afterEvaluate { android.applicationVariants.all { variant -> variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore) } } //tasks.withType(JavaCompile) { //compileTask -> compileTask.dependsOn << [collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore] //} task appStart(type: Exec) { // linux commandLine 'adb', 'shell', 'am', 'start', '-n', 'net.osmand.plus/net.osmand.plus.activities.MapActivity' // windows // commandLine 'cmd', '/c', 'adb', 'shell', 'am', 'start', '-n', 'net.osmand.plus/net.osmand.plus.activities.MapActivity' } repositories { ivy { name = "OsmAndBinariesIvy" url = "http://builder.osmand.net" layout "pattern", { artifact "ivy/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } } mavenCentral() jcenter() maven { url "https://jitpack.io" } } project.logger.warn("Analytics enabled for free version: $analytics") dependencies { compile project(path: ':OsmAnd-java', configuration: 'android') if (analytics) { compile 'com.google.firebase:firebase-core:12.0.1' compile 'com.google.firebase:firebase-messaging:12.0.1' compile 'com.google.firebase:firebase-iid:12.0.1' compile 'com.google.firebase:firebase-config:12.0.1' compile 'com.facebook.android:facebook-android-sdk:4.31.0' } compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:gridlayout-v7:27.1.0' compile 'com.android.support:cardview-v7:27.1.0' compile 'com.android.support:appcompat-v7:27.1.0' compile 'com.android.support:design:27.1.0' compile 'com.android.support:customtabs:27.1.0' compile fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs') compile 'commons-logging:commons-logging-api:1.1' compile 'commons-codec:commons-codec:1.11' compile 'it.unibo.alice.tuprolog:tuprolog:3.2.1' compile 'org.beanshell:bsh-core:2.0b4' compile 'fr.univ-valenciennes:bzip2:1.0' compile 'com.moparisthebest:junidecode:0.1.1' compile 'org.immutables:gson:2.5.0' compile 'com.vividsolutions:jts-core:1.14.0' compile 'com.squareup.picasso:picasso:2.71828' // size restrictions // compile 'com.ibm.icu:icu4j:50.1' // compile 'net.sf.trove4j:trove4j:3.0.3' legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar" qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" compile ("com.getkeepsafe.taptargetview:taptargetview:1.6.1"){ exclude group: 'com.android.support' } compile 'com.github.PhilJay:MPAndroidChart:v3.0.1' compile ("com.github.HITGIF:TextFieldBoxes:1.3.5"){ exclude group: 'com.android.support' } } if(analytics) { println "Apply GMS plugin" apply plugin: 'com.google.gms.google-services' }