330 lines
9.7 KiB
Groovy
330 lines
9.7 KiB
Groovy
plugins {
|
|
// id "com.android.application"
|
|
// id 'org.jetbrains.kotlin.android'
|
|
// id 'kotlin-parcelize'
|
|
// //id 'kotlin-kapt'
|
|
// id 'com.google.devtools.ksp'
|
|
// id "com.google.gms.google-services"
|
|
|
|
alias libs.plugins.android.application
|
|
alias libs.plugins.kotlin.android
|
|
alias libs.plugins.kotlin.parcelize
|
|
alias libs.plugins.room
|
|
alias libs.plugins.ksp
|
|
alias libs.plugins.google.services
|
|
}
|
|
apply from: 'download.gradle'
|
|
|
|
ext {
|
|
versionMajor = 3
|
|
versionMinor = 25
|
|
versionPatch = 9
|
|
}
|
|
|
|
def name = "legado"
|
|
def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
|
|
|
|
ext.versionBuild = gitCommits
|
|
ext.versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
|
|
|
|
def getGitCommitHash() {
|
|
try {
|
|
def stdout = new ByteArrayOutputStream()
|
|
exec {
|
|
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
|
standardOutput = stdout
|
|
}
|
|
return stdout.toString().trim()
|
|
} catch (Exception ignored) {
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
android {
|
|
compileSdk = compile_sdk_version
|
|
namespace 'io.legato.kazusa'
|
|
kotlin {
|
|
jvmToolchain {
|
|
languageVersion.set(JavaLanguageVersion.of(17))
|
|
}
|
|
}
|
|
|
|
signingConfigs {
|
|
if (project.hasProperty("RELEASE_STORE_FILE")) {
|
|
myConfig {
|
|
storeFile file(RELEASE_STORE_FILE)
|
|
storePassword RELEASE_STORE_PASSWORD
|
|
keyAlias RELEASE_KEY_ALIAS
|
|
keyPassword RELEASE_KEY_PASSWORD
|
|
v1SigningEnabled true
|
|
v2SigningEnabled true
|
|
enableV3Signing = true
|
|
enableV4Signing = true
|
|
}
|
|
}
|
|
}
|
|
|
|
defaultConfig {
|
|
applicationId "io.legato.kazusa"
|
|
minSdk 26
|
|
targetSdk 36
|
|
versionCode 10000 + gitCommits
|
|
versionName project.ext.versionName
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
project.ext.set("archivesBaseName", name + "_" + versionName)
|
|
|
|
buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
|
|
buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
|
|
|
|
javaCompileOptions {
|
|
annotationProcessorOptions {
|
|
arguments += [
|
|
"room.incremental" : "true",
|
|
"room.expandProjection": "true",
|
|
"room.schemaLocation" : "$projectDir/schemas".toString()
|
|
]
|
|
}
|
|
}
|
|
|
|
def buildTime = new Date().format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"))
|
|
buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
|
|
}
|
|
|
|
buildFeatures {
|
|
buildConfig true
|
|
viewBinding true
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
if (project.hasProperty("RELEASE_STORE_FILE")) {
|
|
signingConfig signingConfigs.myConfig
|
|
}
|
|
//applicationIdSuffix '.release'
|
|
manifestPlaceholders.put("app_name", "@string/app_name")
|
|
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'cronet-proguard-rules.pro'
|
|
}
|
|
debug {
|
|
applicationIdSuffix ".debug"
|
|
if (project.hasProperty("RELEASE_STORE_FILE")) {
|
|
signingConfig signingConfigs.myConfig
|
|
}
|
|
manifestPlaceholders.put("app_name", "@string/app_name")
|
|
|
|
//applicationIdSuffix '.debug'
|
|
versionNameSuffix "_debug-${getGitCommitHash()}"
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'cronet-proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
splits {
|
|
abi {
|
|
enable true
|
|
reset()
|
|
//noinspection ChromeOsAbiSupport
|
|
include 'armeabi-v7a', 'arm64-v8a'
|
|
universalApk true
|
|
}
|
|
}
|
|
|
|
//noinspection GrDeprecatedAPIUsage
|
|
flavorDimensions = ['mode']
|
|
productFlavors {
|
|
app {
|
|
dimension "mode"
|
|
manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
|
|
}
|
|
}
|
|
|
|
android.applicationVariants.configureEach { variant ->
|
|
variant.outputs.configureEach { output ->
|
|
def abi = output.getFilter(com.android.build.OutputFile.ABI)
|
|
def flavor = variant.productFlavors[0].name
|
|
def baseVersionName = variant.versionName
|
|
def apkName = "${name}_${flavor}_${baseVersionName}"
|
|
if (abi != null) {
|
|
apkName += "_${abi}"
|
|
}
|
|
apkName += ".apk"
|
|
output.outputFileName = apkName
|
|
}
|
|
}
|
|
|
|
|
|
|
|
room {
|
|
schemaDirectory "$projectDir/schemas"
|
|
}
|
|
// 设定Room的KSP参数
|
|
ksp {
|
|
arg("room.incremental", "true")
|
|
arg("room.expandProjection", "true")
|
|
arg("room.generateKotlin", "false")
|
|
//arg("room.schemaLocation", "$projectDir/schemas")
|
|
|
|
}
|
|
|
|
compileOptions {
|
|
// Flag to enable support for the new language APIs
|
|
coreLibraryDesugaringEnabled true
|
|
// Sets Java compatibility
|
|
sourceCompatibility JavaVersion.VERSION_17
|
|
targetCompatibility JavaVersion.VERSION_17
|
|
}
|
|
packaging {
|
|
resources.excludes.add('META-INF/*')
|
|
}
|
|
|
|
sourceSets {
|
|
// Adds exported schema location as test app assets.
|
|
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
|
}
|
|
lint {
|
|
checkDependencies true
|
|
}
|
|
tasks.withType(JavaCompile).tap {
|
|