mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 06:42:21 -04:00
1360 Make abi splits, signing configs and valid release builds intrinsic to an app that applies our plugin - separate custom build logic
This commit is contained in:
parent
188252345e
commit
778fc768ae
@ -1,9 +1,7 @@
|
|||||||
import com.android.build.OutputFile
|
|
||||||
import plugin.KiwixConfigurationPlugin
|
import plugin.KiwixConfigurationPlugin
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("com.github.triplet.play") version("2.4.1")
|
|
||||||
}
|
}
|
||||||
apply plugin: KiwixConfigurationPlugin
|
apply plugin: KiwixConfigurationPlugin
|
||||||
|
|
||||||
@ -50,51 +48,17 @@ android {
|
|||||||
versionName generateVersionName()
|
versionName generateVersionName()
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
|
||||||
release {
|
|
||||||
storeFile file("../kiwix-android.keystore")
|
|
||||||
storePassword System.getenv("KEY_STORE_PASSWORD") ?: "000000"
|
|
||||||
keyAlias System.getenv("KEY_ALIAS") ?: "keystore"
|
|
||||||
keyPassword System.getenv("KEY_PASSWORD") ?: "000000"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
||||||
debug {
|
debug {
|
||||||
multiDexKeepProguard file("multidex-instrumentation-config.pro")
|
multiDexKeepProguard file("multidex-instrumentation-config.pro")
|
||||||
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
|
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
|
||||||
shrinkResources true
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
signingConfig signingConfigs.release
|
|
||||||
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "true"
|
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def abiCodes = ['arm64-v8a': 6, 'x86': 3, 'x86_64': 4, 'armeabi-v7a': 5]
|
|
||||||
def densityCodes = ['mdpi': 2, 'hdpi': 3, 'xhdpi': 4, 'xxhdpi': 5, 'xxxhdpi': 6]
|
|
||||||
splits {
|
|
||||||
density {
|
|
||||||
enable false
|
|
||||||
reset()
|
|
||||||
include "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
applicationVariants.all { variant ->
|
|
||||||
variant.outputs.each { output ->
|
|
||||||
def baseAbiVersionCode = abiCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
|
|
||||||
def baseDensityVersionCode = densityCodes.get(output.getFilter(OutputFile.DENSITY)) ?: 0
|
|
||||||
output.versionCodeOverride =
|
|
||||||
(baseDensityVersionCode * 10000000) +
|
|
||||||
(baseAbiVersionCode * 1000000) +
|
|
||||||
variant.versionCode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
androidTest {
|
androidTest {
|
||||||
java.srcDirs += "$rootDir/core/src/sharedTestFunctions/java"
|
java.srcDirs += "$rootDir/core/src/sharedTestFunctions/java"
|
||||||
@ -103,10 +67,6 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
play {
|
play {
|
||||||
enabled = true
|
|
||||||
serviceAccountCredentials = file("../google.json")
|
|
||||||
track = "alpha"
|
|
||||||
releaseStatus = "draft"
|
|
||||||
resolutionStrategy = "fail"
|
resolutionStrategy = "fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,11 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.android.tools.build:gradle:3.5.0")
|
implementation("com.android.tools.build:gradle:3.5.2")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
|
||||||
implementation("com.dicedmelon.gradle:jacoco-android:0.1.4")
|
implementation("com.dicedmelon.gradle:jacoco-android:0.1.4")
|
||||||
implementation("org.jlleitschuh.gradle:ktlint-gradle:8.2.0")
|
implementation("org.jlleitschuh.gradle:ktlint-gradle:8.2.0")
|
||||||
|
implementation("com.github.triplet.gradle:play-publisher:2.5.0")
|
||||||
implementation(gradleApi())
|
implementation(gradleApi())
|
||||||
implementation(localGroovy())
|
implementation(localGroovy())
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,15 @@
|
|||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import Libs
|
import Libs
|
||||||
|
import com.android.build.VariantOutput
|
||||||
import com.android.build.gradle.AppExtension
|
import com.android.build.gradle.AppExtension
|
||||||
|
import com.android.build.gradle.api.ApkVariantOutput
|
||||||
|
import com.github.triplet.gradle.play.PlayPublisherExtension
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.dependencies
|
import org.gradle.kotlin.dsl.dependencies
|
||||||
import org.gradle.kotlin.dsl.exclude
|
import org.gradle.kotlin.dsl.exclude
|
||||||
import org.gradle.kotlin.dsl.project
|
import org.gradle.kotlin.dsl.project
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class AppConfigurer {
|
class AppConfigurer {
|
||||||
fun configure(target: Project) {
|
fun configure(target: Project) {
|
||||||
@ -31,22 +35,54 @@ class AppConfigurer {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
|
signingConfigs {
|
||||||
|
create("releaseSigningConfig") {
|
||||||
|
this.storeFile = File(target.rootDir, "kiwix-android.keystore")
|
||||||
|
storePassword = System.getenv("KEY_STORE_PASSWORD") ?: "000000"
|
||||||
|
keyAlias = System.getenv("KEY_ALIAS") ?: "keystore"
|
||||||
|
keyPassword = System.getenv("KEY_PASSWORD") ?: "000000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
getByName("release") {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
isShrinkResources = true
|
||||||
|
signingConfig = signingConfigs.getByName("releaseSigningConfig")
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
File("${target.rootDir}/app", "proguard-rules.pro")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
dexOptions {
|
dexOptions {
|
||||||
javaMaxHeapSize = "4g"
|
javaMaxHeapSize = "4g"
|
||||||
}
|
}
|
||||||
|
val abiCodes = mapOf("arm64-v8a" to 6, "x86" to 3, "x86_64" to 4, "armeabi-v7a" to 5)
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
isEnable = true
|
isEnable = true
|
||||||
reset()
|
reset()
|
||||||
include("x86", "x86_64", "armeabi-v7a", "arm64-v8a")
|
include(*abiCodes.keys.toTypedArray())
|
||||||
isUniversalApk = true
|
isUniversalApk = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
applicationVariants.all {
|
||||||
|
outputs.filterIsInstance<ApkVariantOutput>().forEach { output: ApkVariantOutput ->
|
||||||
|
val abiVersionCode = abiCodes[output.getFilter(VariantOutput.FilterType.ABI)] ?: 0
|
||||||
|
output.versionCodeOverride = (abiVersionCode * 1_000_000) + output.versionCode
|
||||||
|
}
|
||||||
|
}
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
cruncherEnabled = true
|
cruncherEnabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
target.plugins.apply("com.github.triplet.play")
|
||||||
|
target.configureExtension<PlayPublisherExtension> {
|
||||||
|
isEnabled = true
|
||||||
|
serviceAccountCredentials = File(target.rootDir, "google.json")
|
||||||
|
track = "alpha"
|
||||||
|
releaseStatus = "draft"
|
||||||
|
}
|
||||||
configureDependencies(target)
|
configureDependencies(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
31
custom/build.gradle.kts
Normal file
31
custom/build.gradle.kts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import com.android.build.gradle.internal.dsl.ProductFlavor
|
||||||
|
import plugin.KiwixConfigurationPlugin
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
android
|
||||||
|
}
|
||||||
|
plugins.apply(KiwixConfigurationPlugin::class)
|
||||||
|
|
||||||
|
android {
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "org.kiwix"
|
||||||
|
}
|
||||||
|
|
||||||
|
flavorDimensions("default")
|
||||||
|
|
||||||
|
// productFlavors {
|
||||||
|
// create("customexample") {
|
||||||
|
// versionName = "2017-07"
|
||||||
|
// versionCode = 1
|
||||||
|
// applicationIdSuffix = ".kiwixcustomexample"
|
||||||
|
// configureStrings("Test Custom App")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(from = File("build_custom.gradle"))
|
||||||
|
|
||||||
|
fun ProductFlavor.configureStrings(appName: String) {
|
||||||
|
resValue("string", "app_name", appName)
|
||||||
|
resValue("string", "app_search_string", "Search $appName")
|
||||||
|
}
|
@ -1,9 +1,6 @@
|
|||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
import plugin.KiwixConfigurationPlugin
|
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: KiwixConfigurationPlugin
|
|
||||||
|
|
||||||
String[] archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
|
String[] archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
|
||||||
|
|
||||||
// Set custom app import directory
|
// Set custom app import directory
|
||||||
@ -12,7 +9,6 @@ def custom = new File("custom/src")
|
|||||||
if (project.hasProperty("customDir")) {
|
if (project.hasProperty("customDir")) {
|
||||||
custom = file(project.property("customDir"))
|
custom = file(project.property("customDir"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up flavours for each custom app in the directory
|
// Set up flavours for each custom app in the directory
|
||||||
if (custom.listFiles()) {
|
if (custom.listFiles()) {
|
||||||
custom.eachFile() { file ->
|
custom.eachFile() { file ->
|
||||||
@ -28,15 +24,6 @@ if (custom.listFiles()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
android {
|
android {
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavorDimensions "default"
|
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
// Custom apps built from a json file, zim file and icon set
|
// Custom apps built from a json file, zim file and icon set
|
||||||
map.each { name, directory ->
|
map.each { name, directory ->
|
21
custom/proguard-rules.pro
vendored
21
custom/proguard-rules.pro
vendored
@ -1,21 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# You can control the set of applied configuration files using the
|
|
||||||
# proguardFiles setting in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
Loading…
x
Reference in New Issue
Block a user