Files
config_apk/build.gradle

98 lines
2.8 KiB
Groovy

plugins {
id 'com.android.application' version '8.7.3'
id 'org.jetbrains.kotlin.android' version '2.0.21'
}
android {
namespace 'app.pawlet.config'
compileSdk 36
defaultConfig {
applicationId 'app.pawlet.config'
minSdk 29
targetSdk 36
versionCode 1
versionName "1.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
// 'assets' = hand-authored files; generated/assets = XMLs copied from submodules
assets.srcDirs = ['assets', "$buildDir/generated/assets"]
java.srcDirs = ['src']
kotlin.srcDirs = ['src']
}
}
buildFeatures {
buildConfig false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.debug
}
debug {
minifyEnabled false
}
}
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.21'
}
// ---------------------------------------------------------------------------
// APN submodule copy tasks
//
// Each entry below copies only *.xml files from a repo submodule into
// build/generated/assets/apns/<name>/ so non-XML files (scripts, schemas,
// YAML, licenses) are never packaged into the APK.
//
// To add a source:
// 1. git submodule add <url> <localDir> (at repo root, not inside assets/)
// 2. Add a copyApns_<name> task below following the same pattern.
//
// To use LineageOS/android_vendor_apn:
// git submodule add https://github.com/LineageOS/android_vendor_apn lineage_apn
// ---------------------------------------------------------------------------
def apnSubmodules = [
// localDir (relative to project root) -> dest name under assets/apns/
'lineage_apn': 'lineage',
]
apnSubmodules.each { srcDir, destName ->
def taskName = "copyApns_${destName}"
tasks.register(taskName, Copy) {
description = "Copy *.xml APN files from ${srcDir}/ into generated assets"
onlyIf { file(srcDir).exists() } // no-op if submodule not initialised
from(srcDir) { include '**/*.xml' }
into "$buildDir/generated/assets/apns/${destName}"
}
}
// Hook all copy tasks into preBuild so every downstream task (assets, lint,
// etc.) sees the generated directory as already populated. preBuild is the
// root lifecycle task — wiring here satisfies Gradle 9.x implicit-dependency
// validation without having to enumerate individual task names.
afterEvaluate {
apnSubmodules.each { srcDir, destName ->
tasks.named('preBuild').configure {
dependsOn("copyApns_${destName}")
}
}
}