OsmAnd/OsmAnd/build.gradle

442 lines
12 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
2018-12-05 20:40:14 +01:00
versionCode 330
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
2018-12-05 20:40:14 +01:00
versionName "3.3.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
}
2019-03-15 13:57:09 +01:00
bundle {
language {
// Specifies that the app bundle should not support
// configuration APKs for language resources. These
// resources are instead packaged with each base and
// dynamic feature APK.
enableSplit = false
}
}
2019-02-21 12:16:25 +01:00
// related to kuromoji
//packagingOptions {
// exclude '/META-INF/CONTRIBUTORS.md'
// exclude '/META-INF/LICENSE.md'
// exclude '/META-INF/NOTICE.md'
//}
2019-02-20 16:17:32 +01:00
2015-01-28 10:58:19 +01:00
// 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 {
2018-08-07 20:24:35 +02:00
jniLibs.srcDirs = ["libc++"]
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 {
2018-07-25 23:56:42 +02:00
abiFilter 'armeabi-v7a'
2015-01-28 10:58:19 +01:00
}
}
2018-07-25 23:54:45 +02:00
arm64 {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
2018-07-25 23:56:42 +02:00
abiFilter 'arm64-v8a'
2015-01-28 10:58:19 +01:00
}
}
x86 {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
2018-07-25 23:56:42 +02:00
abiFilter 'x86'
2015-01-28 10:58:19 +01:00
}
}
2018-07-25 23:54:45 +02:00
fat {
dimension "abi"
2015-01-28 10:58:19 +01:00
ndk {
2018-07-25 23:57:51 +02:00
abiFilters 'arm64-v8a', 'x86', 'armeabi-v7a'
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
}
}
}
}
}
2019-01-31 15:13:55 +01:00
task downloadWorldMiniBasemap {
doLast {
ant.get(src: 'http://builder.osmand.net/basemap/World_basemap_mini_2.obf', dest: 'assets/World_basemap_mini.obf', skipexisting: 'true')
}
}
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 "**/*.js"
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-09-17 17:48:20 +02:00
task copyWidgetIcons(type: Exec) {
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'sh', file("./copy_widget_icons.sh").getAbsolutePath()
}
}
2018-03-30 20:44:00 +02:00
task collectExternalResources {
dependsOn collectVoiceAssets,
2019-01-31 15:13:55 +01:00
collectFonts,
collectHelpContentsAssets,
collectHelpContentsStyle,
copyStyleIcons,
updateNoTranslate,
validateTranslate,
copyWidgetIcons,
downloadWorldMiniBasemap
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) {
2018-08-24 18:38:14 +02:00
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase()
String flavour = "";
if(!tskReqStr.contains("fat")) {
if(tskReqStr.contains("arm64")) {
flavour = flavour.length() == 0 ? "ARM64_ONLY" : ""
}
if(tskReqStr.contains("armv7")) {
flavour = flavour.length() == 0 ? "ARMV7_ONLY" : ""
}
if(tskReqStr.contains("x86")) {
flavour = flavour.length() == 0 ? "X86_ONLY" : ""
}
}
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)) {
2018-08-24 18:38:14 +02:00
if(flavour.length() > 0) {
environment "$flavour", "1"
}
commandLine "bash", file("./old-ndk-build.sh").getAbsolutePath()
2015-01-28 10:58:19 +01:00
} 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 {
2018-08-07 20:24:35 +02:00
file("libc++/armeabi-v7a").mkdirs()
file("libs/armeabi-v7a/libc++_shared.so").renameTo(file("libc++/armeabi-v7a/libc++_shared.so"))
file("libc++/arm64-v8a").mkdirs()
file("libs/arm64-v8a/libc++_shared.so").renameTo(file("libc++/arm64-v8a/libc++_shared.so"))
file("libc++/x86").mkdirs()
file("libs/x86/libc++_shared.so").renameTo(file("libc++/x86/libc++_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 {
2019-02-20 09:15:43 +01:00
implementation project(path: ':OsmAnd-java', configuration: 'android')
if (analytics) {
2019-03-05 12:32:50 +01:00
// Analytics is totally removed to stay free from 3rd party collecting users data
// 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'
2019-02-20 09:15:43 +01:00
}
implementation 'com.android.support:multidex:1.0.1'
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'
2019-02-20 09:25:50 +01:00
implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
2019-02-20 09:15:43 +01:00
implementation 'commons-codec:commons-codec:1.11'
implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1'
implementation 'org.beanshell:bsh-core:2.0b4'
implementation 'org.apache.commons:commons-compress:1.17'
implementation 'com.moparisthebest:junidecode:0.1.1'
implementation 'org.immutables:gson:2.5.0'
implementation 'com.vividsolutions:jts-core:1.14.0'
2019-02-21 12:16:25 +01:00
// turn off for now
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
2019-02-20 09:15:43 +01:00
implementation 'com.squareup.picasso:picasso:2.71828'
// JS core
2019-02-20 09:25:50 +01:00
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
// size restrictions
// implementation 'com.ibm.icu:icu4j:50.1'
// implementation 'net.sf.trove4j:trove4j:3.0.3'
qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
2019-02-20 09:15:43 +01: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"
2019-02-20 09:25:50 +01:00
implementation ("com.getkeepsafe.taptargetview:taptargetview:1.12.0"){
2019-02-20 09:15:43 +01:00
exclude group: 'com.android.support'
}
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
2019-02-20 09:25:50 +01:00
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
2019-02-20 09:15:43 +01: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'
}