141 lines
3.8 KiB
Groovy
141 lines
3.8 KiB
Groovy
plugins {
|
|
id 'com.android.application'
|
|
id 'kotlin-android'
|
|
id "kotlin-kapt"
|
|
// Parcelable 实现生成器
|
|
id "kotlin-parcelize"
|
|
}
|
|
|
|
android {
|
|
compileSdk compile_sdk_version
|
|
|
|
defaultConfig {
|
|
applicationId application_id
|
|
minSdk min_sdk_version
|
|
targetSdk target_sdk_version
|
|
versionCode version_code
|
|
versionName version_name
|
|
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
vectorDrawables {
|
|
useSupportLibrary true
|
|
}
|
|
|
|
//只打包默认资源与英文资源
|
|
resConfigs "en"
|
|
|
|
ndk {
|
|
//只适配armeabi-v7a 架构
|
|
abiFilters "armeabi-v7a"
|
|
}
|
|
|
|
//room
|
|
javaCompileOptions {
|
|
annotationProcessorOptions {
|
|
arguments += [
|
|
//配置并启用将数据库架构导出到给定目录中的json文件的功能
|
|
"room.schemaLocation" : "$projectDir/schemas".toString(),
|
|
//启用gradle增量注解处理器
|
|
"room.incremental" : "true",
|
|
//配置room以重写查询,使其顶部星形投影在展开后包含DAO方法返回类型中定义的列
|
|
"room.expandProjection": "true"]
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = java_version
|
|
useIR = true
|
|
//NetRspKtx 使用了实验特性
|
|
freeCompilerArgs += ["-Xopt-in=kotlin.RequiresOptIn"]
|
|
}
|
|
|
|
buildFeatures {
|
|
compose true
|
|
}
|
|
|
|
signingConfigs {
|
|
debug {
|
|
storeFile file('../linxdebug.keystore')
|
|
storePassword 'linxiang'
|
|
keyAlias 'jiaru'
|
|
keyPassword 'linxiang'
|
|
}
|
|
release {
|
|
storeFile file('../linx.keystore')
|
|
storePassword 'linxxx'
|
|
keyAlias 'jiaru'
|
|
keyPassword 'linxxx'
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
zipAlignEnabled true
|
|
signingConfig signingConfigs.debug
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
|
|
release {
|
|
//开启混淆
|
|
minifyEnabled true
|
|
//去除无用资源
|
|
shrinkResources true
|
|
zipAlignEnabled true
|
|
signingConfig signingConfigs.release
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
composeOptions {
|
|
kotlinCompilerExtensionVersion compose_version
|
|
kotlinCompilerVersion kotlin_version
|
|
}
|
|
|
|
applicationVariants.all { variant ->
|
|
variant.outputs.all {
|
|
outputFileName = "${applicationId}_${getBuildDate()}_${variant.versionName}.apk"
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility java_version
|
|
targetCompatibility java_version
|
|
}
|
|
|
|
packagingOptions {
|
|
resources {
|
|
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取编译日期
|
|
*/
|
|
static String getBuildDate() {
|
|
Date date = new Date()
|
|
String dateStr = date.format("yyyy-MM-dd")
|
|
return dateStr
|
|
}
|
|
|
|
dependencies {
|
|
api project(path: ':common')
|
|
|
|
// 内存泄露检测
|
|
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
|
|
|
|
testImplementation 'junit:junit:4.+'
|
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
|
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
|
|
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
|
|
|
|
//room
|
|
testImplementation "androidx.room:room-testing:$room_version"
|
|
kapt "androidx.room:room-compiler:$room_version"
|
|
|
|
} |