1
0
Fork 0
tt9/app/build.gradle
2024-10-23 12:05:44 +03:00

147 lines
No EOL
3.5 KiB
Groovy

plugins {
id 'com.android.application'
}
apply from: 'constants.gradle'
apply from: 'dictionary-tools.gradle'
apply from: 'help-tools.gradle'
apply from: 'validate-languages.gradle'
apply from: 'version-tools.gradle'
tasks.register('validateLanguages') {
inputs.dir LANGUAGES_INPUT_DIR
outputs.dir LANGUAGE_VALIDATION_DIR
doLast {
validateLanguageFiles(DEFINITIONS_INPUT_DIR, DICTIONARIES_INPUT_DIR, LANGUAGE_VALIDATION_DIR.get().asFile)
}
}
tasks.register('copyDefinitions', Copy) {
from LANGUAGES_INPUT_DIR
include '**/*.yml'
into LANGUAGES_OUTPUT_DIR
}
tasks.register('copyDictionaries', Copy) {
from DICTIONARIES_INPUT_DIR
include '**/*.csv'
include '**/*.txt'
into DICTIONARIES_OUTPUT_DIR
}
tasks.register('convertHelp') {
inputs.dir HELP_MARKDOWN_DIR
outputs.dir HELP_HTML_DIR
doLast {
convertHelpDocs(HELP_MARKDOWN_DIR, HELP_HTML_DIR)
}
}
tasks.register('writeDictionaryProperties') {
inputs.dir fileTree(dir: DICTIONARIES_INPUT_DIR)
outputs.dir DICTIONARY_META_OUTPUT_DIR
doLast {
getDictionaryProperties(DICTIONARIES_INPUT_DIR, DICTIONARY_META_OUTPUT_DIR)
}
}
tasks.register('updateManifest') {
doLast {
updateManifestVersion(getVersionCode(), getVersionName())
}
}
clean {
delete LANGUAGES_OUTPUT_DIR
delete DICTIONARIES_OUTPUT_DIR
delete HELP_HTML_DIR
}
// using the exported Closures directly causes weird values, hence the extra wrappers here
def getVerCode = { -> return getVersionCode() }
def getVerName = { -> return getVersionName() }
def getVersionString = { flavor -> return flavor == 'debug' ? getDebugVersion() : getReleaseVersion() }
android {
namespace PACKAGE_NAME
compileSdk 35
defaultConfig {
applicationId PACKAGE_NAME
minSdk 19
targetSdk 35
versionCode getVerCode()
versionName getVerName()
}
buildFeatures {
buildConfig true
}
buildTypes {
debug {
buildConfigField 'String', 'VERSION_FULL', "\"${getVersionString('debug')}\""
}
release {
buildConfigField 'String', 'VERSION_FULL', "\"${getVersionString('release')}\""
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
flavorDimensions = ['app']
productFlavors {
full {
dimension 'app'
buildConfigField 'Boolean', 'LITE', 'false'
}
lite {
dimension 'app'
buildConfigField 'Boolean', 'LITE', 'true'
}
}
applicationVariants.configureEach { variant ->
[
"merge${variant.name.capitalize()}Assets",
"lintAnalyze${variant.name.capitalize()}",
"generate${variant.name.capitalize()}LintReportModel",
"lintVitalAnalyze${variant.name.capitalize()}",
"generate${variant.name.capitalize()}LintVitalReportModel"
].each { taskName ->
try {
tasks.named(taskName)?.configure {
dependsOn(validateLanguages, copyDefinitions, copyDictionaries, writeDictionaryProperties, convertHelp)
}
} catch (UnknownTaskException ignored) {}
}
assembleLiteDebug.finalizedBy(updateManifest)
assembleFullDebug.finalizedBy(updateManifest)
assembleLiteRelease.finalizedBy(updateManifest)
assembleFullRelease.finalizedBy(updateManifest)
variant.outputs.configureEach {
def suffix = variant.flavorName == 'full' ? '-full' : ''
outputFileName = "${APP_NAME}-v${getVerName()}${suffix}.apk"
}
}
}
dependencies {
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}