OsmAnd/OsmAnd/build.gradle

330 lines
8.1 KiB
Groovy
Raw Normal View History

2014-12-16 12:23:45 +01:00
apply plugin: 'com.android.application'
2015-01-21 23:32:16 +01:00
// Global Paramers accepted
// 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-01-21 13:43:07 +01:00
// TODO
2015-01-21 23:32:16 +01:00
// 1. 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 23:32:16 +01:00
// 2. fix_apostrophe_issues (replace match="[^=]([^\\])'" replace="\1\\\\'") res/**/strings.xml
// 3. sherpafy/free/paid
// 4. Release signature
2015-01-27 00:03:55 +01:00
// 5. TARGET_APP_NAME, APP_EDITION uses flavor
2015-01-21 00:51:32 +01:00
2014-12-16 12:23:45 +01:00
android {
2015-01-28 10:58:19 +01:00
compileSdkVersion 21
buildToolsVersion "21.1.2"
signingConfigs {
development {
storeFile file("../keystores/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
publishing {
storeFile file("osmand_key")
storePassword System.getenv("OSMAND_APK_PASSWORD")
2015-01-28 10:58:19 +01:00
keyAlias "androiddebugkey"
keyPassword System.getenv("OSMAND_APK_PASSWORD")
2015-01-28 10:58:19 +01:00
}
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
//versionName already assigned in code
//versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").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"
}
dexOptions {
jumboMode = true
}
sourceSets {
main {
manifest.srcFile "AndroidManifest.xml"
jni.srcDirs = []
jniLibs.srcDirs = ["libs"]
aidl.srcDirs = ["src"]
java.srcDirs = [
"src",
fileTree(dir: "../OsmAnd-java/src", exclude: "**/PlatformUtil.java")
]
resources.srcDirs = [
"src"
]
renderscript.srcDirs = ["src"]
res.srcDirs = [
'res'
]
assets.srcDirs = [
'assets'
]
}
free {
manifest.srcFile "AndroidManifest-free.xml"
}
legacy {
jniLibs.srcDirs = [
"libgnustl"
]
}
}
flavorDimensions "version", "coreversion", "abi"
productFlavors {
// ABI
armv7 {
flavorDimension "abi"
ndk {
abiFilter "armeabi-v7a"
}
}
armv5 {
flavorDimension "abi"
ndk {
abiFilter "armeabi"
}
}
x86 {
flavorDimension "abi"
ndk {
abiFilter "x86"
}
}
mips {
flavorDimension "abi"
ndk {
abiFilter "mips"
}
}
fat {
flavorDimension "abi"
}
// Version
free {
flavorDimension "version"
applicationId "net.osmand"
}
full {
flavorDimension "version"
applicationId "net.osmand.plus"
}
// CoreVersion
legacy {
flavorDimension "coreversion"
}
qtcore {
flavorDimension "coreversion"
}
qtcoredebug {
flavorDimension "coreversion"
}
}
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") + "<")
}
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")) {
// appends build number to version number for dev builds
return line.replaceAll("</", System.getenv("APK_VERSION") + "</")
}
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
inputs.property 'appName', System.getenv().get("APP_NAME")
inputs.property 'appEdition', System.getenv().get("APP_EDITION")
inputs.property 'appFeatures', System.getenv().get("APP_FEATURES")
inputs.property 'apkVersion', System.getenv().get("APK_VERSION")
from('.') {
include 'no_translate.xml'
filter {
line -> replaceNoTranslate(line);
}
}
into 'res/values/'
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
}
2015-01-21 13:43:07 +01:00
task collectSpecialPhrasesAssets(type: Sync) {
2015-01-28 10:58:19 +01:00
from "../../resources/specialphrases"
into "assets/specialphrases"
include "*.txt"
2015-01-21 13:43:07 +01:00
}
2015-01-21 23:32:16 +01:00
task collectHelpContentsAssets(type: Sync) {
2015-01-28 10:58:19 +01:00
from "../../help"
into "assets/help"
include "*.html"
include "images/**/*.png"
from "assets/"
into "assets/help"
include "style.css"
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-01-28 10:58:19 +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-01-28 10:58:19 +01:00
collectSpecialPhrasesAssets,
collectHelpContentsAssets,
collectRoutingResources,
collectRenderingStylesResources,
collectRegionsInfoResources,
collectMiscResources,
copyStyleIcons,
updateNoTranslate
2015-01-24 17:22:46 +01:00
tasks.whenTaskAdded { task ->
2015-01-28 10:58:19 +01:00
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()
println file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so"))
file("libgnustl/armeabi-v7a").mkdirs()
println file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so"))
file("libgnustl/mips").mkdirs()
println file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so"))
file("libgnustl/x86").mkdirs()
println file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so"))
}
2014-12-17 17:35:16 +01:00
}
2014-12-17 16:32:31 +01:00
tasks.withType(JavaCompile) {
2015-01-28 10:58:19 +01:00
compileTask -> compileTask.dependsOn << [buildOsmAndCore, cleanupDuplicatesInCore]
2015-01-23 13:32:07 +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]"
}
}
2014-12-16 12:23:45 +01:00
}
dependencies {
2015-01-28 10:58:19 +01:00
compile fileTree(
dir: "libs",
include: ["*.jar"],
exclude: [
"QtAndroid-bundled.jar",
"QtAndroidAccessibility-bundled.jar",
"android-support*.jar",
"OsmAndCore_android.jar",
"OsmAndCore_wrapper.jar"])
compile "com.android.support:appcompat-v7:21.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"
2014-12-16 12:23:45 +01:00
}