OsmAnd/OsmAnd/build.gradle

390 lines
11 KiB
Groovy
Raw Normal View History

2014-12-16 12:23:45 +01:00
apply plugin: 'com.android.application'
2018-03-28 23:03:17 +02:00
2015-04-23 17:26:29 +02:00
// Global Parameters accepted
2017-06-03 12:06:51 +02:00
// TARGET_APP_NAME - app name
2015-01-21 23:32:16 +01:00
// APK_NUMBER_VERSION - version number of apk
2017-06-03 13:40:07 +02:00
// 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
2017-06-03 12:06:51 +02:00
// APP_EDITION - date stamp of builds
// APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon
2015-01-21 23:32:16 +01:00
2015-04-24 23:20:54 +02:00
// 1. To be done Filter fonts
2015-01-21 00:51:32 +01:00
// <unzip src="OsmAndCore_android.aar" dest=".">
// <patternset>
// <include name="assets/**/map/fonts/OpenSans/*"/>
// <include name="assets/**/map/fonts/NotoSans/*"/>
// </patternset>
// </unzip>
2015-01-23 13:32:07 +01:00
// Less important
2015-01-21 00:51:32 +01:00
2018-03-28 23:03:17 +02:00
// Configure eclipse-aar plugin
2018-03-30 21:08:06 +02:00
def analytics = (!System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+play_market")) &&
getGradle().getStartParameter().getTaskRequests().toString().contains("Free")
2018-03-28 23:03:17 +02:00
2018-04-15 02:51:24 +02:00
task printc {
configurations.each { if(it.isCanBeResolved()) println it.name }
2018-03-28 23:03:17 +02:00
}
2014-12-16 12:23:45 +01:00
android {
2018-03-28 23:03:17 +02:00
compileSdkVersion 27
buildToolsVersion "27.0.3"
2015-01-28 10:58:19 +01:00
signingConfigs {
development {
storeFile file("../keystores/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
publishing {
2015-04-23 17:39:46 +02:00
storeFile file("/var/lib/jenkins/osmand_key")
storePassword System.getenv("OSMAND_APK_PASSWORD")
2015-04-23 17:26:29 +02:00
keyAlias "osmand"
keyPassword System.getenv("OSMAND_APK_PASSWORD")
2015-01-28 10:58:19 +01:00
}
}
defaultConfig {
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() :
(analytics ? 15 : 14)
targetSdkVersion 26
2017-10-20 11:22:28 +02:00
versionCode 300
2015-01-28 10:58:19 +01:00
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
2015-11-26 11:27:16 +01:00
multiDexEnabled true
versionName "3.0.0"
2016-02-19 12:23:26 +01:00
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
2015-01-28 10:58:19 +01:00
}
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"
2017-05-05 13:20:55 +02:00
cruncherEnabled = false
2015-01-28 10:58:19 +01:00
}
dexOptions {
2015-11-26 11:27:16 +01:00
javaMaxHeapSize "4g"
2015-01-28 10:58:19 +01:00
}
sourceSets {
main {
manifest.srcFile "AndroidManifest.xml"
jni.srcDirs = []
jniLibs.srcDirs = ["libs"]
aidl.srcDirs = ["src"]
2015-02-02 16:54:43 +01:00
java.srcDirs = ["src"]
2016-06-16 17:14:22 +02:00
resources.srcDirs = ["src"]
2015-01-28 10:58:19 +01:00
renderscript.srcDirs = ["src"]
2015-02-02 16:54:43 +01:00
res.srcDirs = ["res"]
assets.srcDirs = ["assets"]
2015-01-28 10:58:19 +01:00
}
2018-05-02 22:06:06 +02:00
debug {
manifest.srcFile "AndroidManifest-debug.xml"
}
2015-01-28 10:58:19 +01:00
free {
manifest.srcFile "AndroidManifest-free.xml"
}
2016-01-27 22:46:25 +01:00
freedev {
manifest.srcFile "AndroidManifest-freedev.xml"
}
2018-03-30 23:57:21 +02:00
freecustom {
manifest.srcFile "AndroidManifest-freecustom.xml"
}
2015-01-28 10:58:19 +01:00
legacy {
2015-02-02 16:54:43 +01:00
jniLibs.srcDirs = ["libgnustl"]
2015-01-28 10:58:19 +01:00
}
}
flavorDimensions "version", "coreversion", "abi"
productFlavors {
// ABI
armv7 {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
abiFilter "armeabi-v7a"
}
}
armv5 {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
abiFilter "armeabi"
}
}
x86 {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
abiFilter "x86"
}
}
mips {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
abiFilter "mips"
}
}
fat {
dimension "abi"
2015-01-28 10:58:19 +01:00
}
// Version
2016-01-27 22:46:25 +01:00
freedev {
dimension "version"
2016-01-27 22:46:25 +01:00
applicationId "net.osmand.dev"
2017-03-25 12:36:51 +01:00
// resConfig "en"
2016-01-27 22:46:25 +01:00
}
2015-01-28 10:58:19 +01:00
free {
dimension "version"
2015-01-28 10:58:19 +01:00
applicationId "net.osmand"
}
2017-04-18 14:26:26 +02:00
freeres {
dimension "version"
applicationId "net.osmand"
resConfig "en"
}
2018-03-30 23:57:21 +02:00
freecustom {
dimension "version"
applicationId "net.osmand.freecustom"
}
2015-01-28 10:58:19 +01:00
full {
dimension "version"
2015-01-28 10:58:19 +01:00
applicationId "net.osmand.plus"
}
2017-02-15 17:15:23 +01:00
fulldev {
dimension "version"
applicationId "net.osmand.plus"
resConfig "en"
//resConfigs "xxhdpi", "nodpi"
}
2015-01-28 10:58:19 +01:00
// CoreVersion
legacy {
dimension "coreversion"
2015-01-28 10:58:19 +01:00
}
qtcore {
dimension "coreversion"
2015-01-28 10:58:19 +01:00
}
qtcoredebug {
dimension "coreversion"
2015-01-28 10:58:19 +01:00
}
}
buildTypes {
debug {
signingConfig signingConfigs.development
}
release {
signingConfig signingConfigs.publishing
}
2015-01-26 12:30:23 +01:00
}
2015-01-21 23:32:16 +01:00
}
2015-01-21 02:58:28 +01:00
2015-01-21 23:32:16 +01:00
def replaceNoTranslate(line) {
2015-01-28 10:58:19 +01:00
if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
}
2016-11-13 11:37:13 +01:00
if (line.contains("\"app_name_free\"") && System.getenv("TARGET_APP_NAME")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
}
2015-01-28 10:58:19 +01:00
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;
2015-01-21 23:32:16 +01:00
}
task updateNoTranslate(type: Copy) {
2015-01-28 10:58:19 +01:00
from('.') {
include 'no_translate.xml'
filter {
line -> replaceNoTranslate(line);
}
}
into 'res/values/'
2014-12-17 16:32:31 +01:00
}
2015-11-25 12:11:25 +01:00
task validateTranslate {
2015-11-26 11:27:16 +01:00
println "Validating translations"
2015-11-25 12:23:37 +01:00
file("res").eachFileRecurse groovy.io.FileType.FILES, {
2015-11-26 11:27:16 +01:00
if (it.name == "strings.xml" || it.name == "phrases.xml") {
2015-11-25 12:11:25 +01:00
it.eachLine { line ->
2015-11-26 11:27:16 +01:00
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);
2015-11-25 12:11:25 +01:00
}
}
}
}
}
2014-12-17 16:32:31 +01:00
task collectVoiceAssets(type: Sync) {
2015-01-28 10:58:19 +01:00
from "../../resources/voice"
into "assets/voice"
include "**/*.p"
2014-12-17 16:32:31 +01:00
}
2016-06-23 01:09:35 +02:00
task cleanNoTranslate(type: Delete) {
delete('res/values/no_translate.xml')
}
2015-09-09 18:22:47 +02:00
task collectFonts(type: Copy) {
2017-02-26 13:59:10 +01:00
from "../../resources/fonts"
2016-12-29 12:29:18 +01:00
from "../../resources/rendering_styles/fonts"
2016-12-12 13:58:22 +01:00
// from "../../resources/rendering_styles/fonts/OpenSans"
2015-09-09 18:22:47 +02:00
into "assets/fonts"
include "*.ttf"
}
2015-11-07 18:49:05 +01:00
task collectHelpContentsStyle(type: Copy) {
2015-11-07 19:09:36 +01:00
from("../../help/website/help/") {
2015-11-07 18:49:05 +01:00
include "style.css"
2015-11-03 15:39:13 +01:00
}
2015-11-07 18:49:05 +01:00
into "assets"
}
task collectHelpContentsAssets(type: Copy) {
from("../../help/website/help") {
include "about.html"
2015-11-07 18:49:05 +01:00
include "changes.html"
include "faq.html"
include "technical-articles.html"
2015-11-08 09:54:35 +01:00
include "map-legend.html"
2015-11-03 15:39:13 +01:00
}
2015-11-26 11:27:16 +01:00
from("../../help/website/feature_articles") {
2015-11-03 15:39:13 +01:00
include "*.html"
}
2015-11-03 09:46:06 +01:00
into "assets/feature_articles"
2015-01-21 23:32:16 +01:00
}
2014-12-17 16:32:31 +01:00
2015-01-21 23:32:16 +01:00
task copyStyleIcons(type: Copy) {
2015-01-28 10:58:19 +01:00
from "../../resources/rendering_styles/style-icons/"
into "res/"
include "**/*.png"
2014-12-17 16:32:31 +01:00
}
2018-03-30 20:44:00 +02:00
task collectExternalResources {
dependsOn collectVoiceAssets,
2015-09-09 18:22:47 +02:00
collectFonts,
2015-01-28 10:58:19 +01:00
collectHelpContentsAssets,
2015-11-07 18:49:05 +01:00
collectHelpContentsStyle,
2015-01-28 10:58:19 +01:00
copyStyleIcons,
2015-11-25 12:11:25 +01:00
updateNoTranslate,
validateTranslate
2018-03-30 20:44:00 +02:00
}
2015-01-21 10:52:10 +01:00
2014-12-17 16:32:31 +01:00
// Legacy core build
import org.apache.tools.ant.taskdefs.condition.Os
2015-01-28 10:58:19 +01:00
2014-12-17 16:32:31 +01:00
task buildOsmAndCore(type: Exec) {
2015-01-28 10:58:19 +01:00
description "Build Legacy OsmAndCore"
2014-12-17 16:32:31 +01:00
2015-01-28 10:58:19 +01:00
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "bash", file("./old-ndk-build.sh").getAbsolutePath()
} else {
commandLine "cmd", "/c", "echo", "Not supported"
}
2014-12-17 16:32:31 +01:00
}
2015-01-23 13:32:07 +01:00
task cleanupDuplicatesInCore() {
2015-01-28 10:58:19 +01:00
dependsOn buildOsmAndCore
// doesn't work for legacy debug builds
doLast {
file("libgnustl/armeabi").mkdirs()
2015-05-02 11:30:02 +02:00
file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so"))
2015-01-28 10:58:19 +01:00
file("libgnustl/armeabi-v7a").mkdirs()
2015-05-02 11:30:02 +02:00
file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so"))
2015-01-28 10:58:19 +01:00
file("libgnustl/mips").mkdirs()
2015-05-02 11:30:02 +02:00
file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so"))
2015-01-28 10:58:19 +01:00
file("libgnustl/x86").mkdirs()
2015-05-02 11:30:02 +02:00
file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so"))
2015-01-28 10:58:19 +01:00
}
2014-12-17 17:35:16 +01:00
}
2018-03-30 20:44:00 +02:00
afterEvaluate {
android.applicationVariants.all { variant ->
variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore)
}
2015-01-23 13:32:07 +01:00
}
2015-12-17 14:09:51 +01:00
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'
2015-12-17 14:09:51 +01:00
}
2014-12-16 12:23:45 +01:00
2018-03-30 21:08:06 +02:00
project.logger.warn("Analytics enabled for free version: $analytics")
2014-12-16 12:23:45 +01:00
dependencies {
2018-04-15 02:51:24 +02:00
implementation project(path: ':OsmAnd-java', configuration: 'android')
2017-01-06 16:33:05 +01:00
if (analytics) {
2018-04-15 02:51:24 +02:00
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-iid:12.0.1'
implementation 'com.google.firebase:firebase-config:12.0.1'
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
}
2018-04-15 02:51:24 +02:00
implementation 'com.android.support:multidex:1.0.1'
2018-06-11 14:39:04 +02:00
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
2018-04-15 02:51:24 +02:00
implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
2018-06-15 16:51:56 +02:00
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
2018-04-15 02:51:24 +02:00
implementation 'commons-codec:commons-codec:1.11'
2018-06-02 13:17:47 +02:00
implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1'
implementation 'org.beanshell:bsh-core:2.0b4'
2018-06-15 16:51:56 +02:00
implementation 'org.apache.commons:commons-compress:1.17'
2018-06-02 13:17:47 +02:00
implementation 'com.moparisthebest:junidecode:0.1.1'
implementation 'org.immutables:gson:2.5.0'
implementation 'com.vividsolutions:jts-core:1.14.0'
2018-04-15 02:51:24 +02:00
implementation 'com.squareup.picasso:picasso:2.71828'
2018-03-31 00:36:19 +02:00
// size restrictions
2018-04-15 02:51:24 +02:00
// implementation 'com.ibm.icu:icu4j:50.1'
// implementation 'net.sf.trove4j:trove4j:3.0.3'
2018-06-02 13:17:47 +02:00
2018-04-15 02:51:24 +02:00
legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
implementation ("com.getkeepsafe.taptargetview:taptargetview:1.6.1"){
2017-01-06 16:33:05 +01:00
exclude group: 'com.android.support'
}
2018-04-15 02:51:24 +02:00
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
2017-09-25 15:55:29 +02:00
exclude group: 'com.android.support'
}
2014-12-16 12:23:45 +01:00
}
if(analytics) {
2016-11-10 15:38:15 +01:00
println "Apply GMS plugin"
apply plugin: 'com.google.gms.google-services'
}