OsmAnd/OsmAnd/build.gradle

399 lines
11 KiB
Groovy
Raw Normal View History

2014-12-16 12:23:45 +01:00
apply plugin: 'com.android.application'
2015-04-23 17:26:29 +02:00
// Global Parameters accepted
2015-01-21 23:32:16 +01:00
// APK_NUMBER_VERSION - version number of apk
2015-01-27 00:25:40 +01:00
// APK_VERSION - build number like #9999Z, for dev builds appended to app_version like 2.0.0 in no_translate.xml)
// flavor Z : M=-master, D=-design, B=-Blackberry, MD=-main-default, MQA=-main-qt-arm, MQDA=-main-qt-default-arm, S=-sherpafy
2015-01-27 00:03:55 +01:00
// TARGET_APP_NAME - app name
2015-01-27 00:25:40 +01:00
// APP_EDITION - date stamp of builds
2015-01-21 23:32:16 +01:00
// APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon
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
2014-12-16 12:23:45 +01:00
android {
2015-11-26 11:27:16 +01:00
compileSdkVersion 23
2016-04-13 15:25:42 +02:00
buildToolsVersion "23.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 {
2015-11-27 21:15:13 +01:00
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 14
targetSdkVersion 23
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
2016-02-19 12:23:26 +01:00
versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").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"
}
dexOptions {
2015-11-26 11:27:16 +01:00
incremental true
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
}
free {
manifest.srcFile "AndroidManifest-free.xml"
}
2016-01-27 22:46:25 +01:00
freedev {
manifest.srcFile "AndroidManifest-freedev.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"
}
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 {
2015-11-03 15:39:13 +01:00
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
// minifyEnabled true
// proguardFiles 'proguard-project.txt'
2015-01-28 10:58:19 +01:00
signingConfig signingConfigs.development
}
release {
2015-11-03 15:39:13 +01:00
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
// minifyEnabled true
//proguardFiles 'proguard-project.txt'
2015-01-28 10:58:19 +01:00
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("\"app_version\"") && System.getenv("APK_VERSION")) {
2015-04-28 19:57:26 +02:00
return line.replaceAll(">[^<]*<", ">" + System.getenv("APK_VERSION") + "<")
}
if (line.contains("\"app_version\"") && System.getenv("APK_VERSION_SUFFIX")) {
2015-01-28 10:58:19 +01:00
// appends build number to version number for dev builds
2015-04-28 19:57:26 +02:00
return line.replaceAll("</", System.getenv("APK_VERSION_SUFFIX") + "</")
2015-01-28 10:58:19 +01:00
}
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
task collectRoutingResources(type: Sync) {
2015-01-28 10:58:19 +01:00
from "../../resources/routing"
into "src/net/osmand/router"
include "*.xml"
2014-12-17 16:32:31 +01:00
}
2015-01-21 23:32:16 +01:00
task collectMiscResources(type: Copy) {
2015-11-03 15:39:13 +01:00
into "src/net/osmand/osm"
from("../../resources/obf_creation") {
include "rendering_types.xml"
}
from("../../resources/poi") {
include "poi_types.xml"
}
2015-01-21 23:32:16 +01:00
}
2015-01-21 13:43:07 +01:00
task collectRenderingStylesResources(type: Sync) {
2015-01-28 10:58:19 +01:00
from "../../resources/rendering_styles"
into "src/net/osmand/render"
include "*.xml"
2014-12-17 16:32:31 +01:00
}
2015-01-21 13:43:07 +01:00
task collectRegionsInfoResources(type: Copy) {
2015-01-28 10:58:19 +01:00
from "../../resources/countries-info"
into "src/net/osmand/map"
include "regions.ocbf"
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
}
task collectExternalResources << {}
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
collectRoutingResources,
collectRenderingStylesResources,
collectRegionsInfoResources,
collectMiscResources,
copyStyleIcons,
2015-11-25 12:11:25 +01:00
updateNoTranslate,
validateTranslate
2015-04-28 22:36:04 +02:00
// tasks.whenTaskAdded { task ->
// if (task.name.startsWith("generate") && task.name.endsWith("Resources")) {
// task.dependsOn collectExternalResources
// }
// }
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
}
2014-12-17 16:32:31 +01:00
tasks.withType(JavaCompile) {
2015-04-28 21:30:34 +02:00
compileTask -> compileTask.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-17 16:32:31 +01:00
repositories {
2015-01-28 10:58:19 +01:00
ivy {
name = "OsmAndBinariesIvy"
url = "http://builder.osmand.net"
layout "pattern", {
artifact "ivy/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
}
}
2017-01-06 22:55:28 +01:00
mavenCentral()
2017-01-07 00:06:34 +01:00
jcenter()
2017-02-12 13:37:57 +01:00
maven {
url "https://jitpack.io"
}
2014-12-16 12:23:45 +01:00
}
def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") &&
System.getenv("PACKAGE_TO_BUILT").equals("net.osmand") ) || System.getenv("USE_FIREBASE")
2014-12-16 12:23:45 +01:00
dependencies {
2015-11-18 10:58:29 +01:00
compile project(path: ':OsmAnd-java', configuration: 'android')
2017-01-06 16:33:05 +01:00
if (analytics) {
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-config:9.8.0'
}
2016-05-06 22:56:48 +02:00
// compile project(':eclipse-compile:design')
// compile project(':eclipse-compile:cardview')
// compile project(':eclipse-compile:gridlayout')
compile 'com.android.support:gridlayout-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
2017-01-06 16:33:05 +01:00
compile 'com.android.support:design:23.3.0'
compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs')
2015-01-28 10:58:19 +01:00
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"
2017-01-06 16:33:05 +01:00
compile ("com.getkeepsafe.taptargetview:taptargetview:1.6.1"){
exclude group: 'com.android.support'
}
2017-02-12 13:37:57 +01:00
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
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'
}