SmsForwarder/app/build.gradle

361 lines
14 KiB
Groovy
Raw Normal View History

2023-12-17 12:04:18 +00:00
//file:noinspection DependencyNotationArgument
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
2023-01-20 03:10:08 +00:00
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'img-optimizer'
id 'com.yanzhenjie.andserver'
}
def keyProps = new Properties()
def keyPropsFile = rootProject.file('keystore/keystore.properties')
if (keyPropsFile.exists()) {
keyProps.load(new FileInputStream(keyPropsFile))
}
//打包时记得设置true启用
if (isNeedPackage.toBoolean() && isUseBooster.toBoolean()) {
apply plugin: 'com.didiglobal.booster'
}
android {
buildToolsVersion build_versions.build_tools
compileSdkVersion build_versions.target_sdk
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
//编译日期
def buildDate = new Date().format("yyMMdd", TimeZone.getTimeZone("GMT+08"))
//编译时间
def buildTime = new Date().format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("GMT+08"))
//Git 的 Commit ID
def gitCommitId = getGitCommitId()
2023-01-20 03:10:08 +00:00
defaultConfig {
applicationId "com.idormy.sms.forwarder"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode build_versions.version_code
versionName = "${build_versions.version_name}.${buildDate}"
2023-01-20 03:10:08 +00:00
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
buildConfigField "String", "GIT_COMMIT_ID", "\"${gitCommitId}\""
2023-01-20 03:10:08 +00:00
multiDexEnabled true
//vectorDrawables.useSupportLibrary = true
2023-01-20 03:10:08 +00:00
javaCompileOptions {
annotationProcessorOptions {
arguments = [moduleName: project.getName()]
}
}
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
signingConfigs {
release {
keyAlias keyProps['keyAlias']
keyPassword keyProps['keyPassword']
storeFile keyProps['storeFile'] ? file(keyProps['storeFile']) : null
storePassword keyProps['storePassword']
}
debug {
keyAlias keyProps['keyAlias']
keyPassword keyProps['keyPassword']
storeFile keyProps['storeFile'] ? file(keyProps['storeFile']) : null
storePassword keyProps['storePassword']
}
}
buildTypes {
release {
2023-02-09 16:17:15 +00:00
// 调试模式开关
debuggable false
jniDebuggable false
// 移除无用的资源
2023-01-20 03:10:08 +00:00
shrinkResources true
2023-02-09 16:17:15 +00:00
// 代码混淆开关
minifyEnabled true
// 混淆配置
2023-01-20 03:10:08 +00:00
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (isNeedPackage.toBoolean()) {
signingConfig signingConfigs.release
if (file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def appID = properties.getProperty("APP_ID_UMENG")
if (appID != null) {
buildConfigField "String", "APP_ID_UMENG", appID
} else {
buildConfigField "String", "APP_ID_UMENG", '"60254fc7425ec25f10f4293e"'
}
} else {
buildConfigField "String", "APP_ID_UMENG", '"60254fc7425ec25f10f4293e"'
}
} else {
signingConfig signingConfigs.debug
buildConfigField "String", "APP_ID_UMENG", '"60254fc7425ec25f10f4293e"'
}
}
debug {
2023-02-09 16:17:15 +00:00
// 调试模式开关
debuggable true
jniDebuggable true
// 移除无用的资源
2023-01-20 03:10:08 +00:00
shrinkResources true
2023-02-09 16:17:15 +00:00
// 代码混淆开关
minifyEnabled true
// 混淆配置
2023-01-20 03:10:08 +00:00
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (isNeedPackage.toBoolean()) {
signingConfig signingConfigs.release
if (file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def appID = properties.getProperty("APP_ID_UMENG")
if (appID != null) {
buildConfigField "String", "APP_ID_UMENG", appID
} else {
buildConfigField "String", "APP_ID_UMENG", '"60254fc7425ec25f10f4293e"'
}
} else {
buildConfigField "String", "APP_ID_UMENG", '"60254fc7425ec25f10f4293e"'
}
} else {
signingConfig signingConfigs.debug
buildConfigField "String", "APP_ID_UMENG", '"60254fc7425ec25f10f4293e"'
}
}
}
//ABI配置——按CPU架构分别打包
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
def abiCodes = ['universal': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'x86': 4, 'x86_64': 5]
packagingOptions {
//去除FrpcLib的so用时下载并动态加载
2023-02-11 11:38:34 +00:00
if (excludeFrpclib.toBoolean()) {
2023-01-20 03:10:08 +00:00
exclude 'lib/armeabi-v7a/libgojni.so'
exclude 'lib/arm64-v8a/libgojni.so'
exclude 'lib/x86/libgojni.so'
exclude 'lib/x86_64/libgojni.so'
}
resources {
pickFirst 'META-INF/LICENSE.md'
pickFirst 'META-INF/NOTICE.md'
excludes += ['META-INF/DEPENDENCIES.txt', 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES', 'META-INF/notice.txt', 'META-INF/license.txt', 'META-INF/dependencies.txt', 'META-INF/LGPL2.1']
}
}
2023-02-09 16:17:15 +00:00
2023-12-17 12:04:18 +00:00
android.applicationVariants.configureEach { variant ->
2023-12-01 14:37:37 +00:00
variant.outputs.each { output ->
//noinspection GrDeprecatedAPIUsage
2023-12-01 14:37:37 +00:00
def abiName = output.getFilter(com.android.build.OutputFile.ABI)
if (abiName == null) abiName = "universal"
output.versionCodeOverride = abiCodes.get(abiName, 0) * 100000 + variant.versionCode
output.outputFileName = "SmsF_${versionName}_${output.versionCode}_${abiName}_${variant.name}.apk"
// 修改 output-metadata.json 追加编译日期、编译时间、Git Commit ID
def assembleTaskName = "assemble${variant.name.capitalize()}"
tasks.named(assembleTaskName) {
doLast {
def metadataFile = file("${output.outputFile.parent}/output-metadata.json")
def metadata = new JsonSlurper().parseText(metadataFile.text)
metadata.buildDate = buildDate
metadata.buildTime = buildTime
metadata.gitCommitId = gitCommitId
metadataFile.text = new JsonBuilder(metadata).toPrettyString()
}
}
2023-01-20 03:10:08 +00:00
}
}
bundle {
language {
enableSplit = false
}
}
2023-01-20 03:10:08 +00:00
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
lint {
abortOnError false
}
namespace 'com.idormy.sms.forwarder'
//编译前清理项目缓存
preBuild.dependsOn clean
//编译后清理垃圾文件
gradle.buildFinished { buildResult ->
if (buildResult.failure == null) {
println "Build succeeded, cleaning text files..."
//delete rootProject.buildDir
FileTree rootTree = fileTree(dir: rootDir)
rootTree.each { File file ->
if ((file.toString().contains("ajcore") || file.toString().contains("mapping") || file.toString().contains("seeds") || file.toString().contains("unused")) && file.toString().endsWith(".txt")) {
delete file
}
}
} else {
println "Build failed, cleanTxt not executed."
}
}
2023-01-20 03:10:08 +00:00
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//frpc
implementation files('libs/frpclib.aar')
//MQTT协议
implementation("org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5")
2023-01-20 03:10:08 +00:00
testImplementation deps.junit
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
2023-01-20 03:10:08 +00:00
androidTestImplementation deps.espresso.core
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-29 03:42:10 +00:00
implementation 'androidx.core:core-ktx:1.9.0'
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-29 03:42:10 +00:00
implementation 'androidx.activity:activity-ktx:1.6.1'
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-29 03:42:10 +00:00
implementation 'androidx.fragment:fragment-ktx:1.5.5'
2023-01-20 03:10:08 +00:00
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.appcompat:appcompat:1.6.1'
2023-10-20 07:22:02 +00:00
implementation 'androidx.preference:preference-ktx:1.2.1'
2023-01-20 03:10:08 +00:00
//分包
implementation deps.androidx.multidex
//vLayouthttps://github.com/alibaba/vlayout
implementation 'com.alibaba.android:vlayout:1.3.0'
//下拉刷新
implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-header:1.1.5'
implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-layout:1.1.5'
//WebView
implementation 'com.github.xuexiangjys.AgentWeb:agentweb-core:1.0.1'
implementation 'com.github.xuexiangjys.AgentWeb:agentweb-download:1.0.1'//选填
2023-01-20 03:10:08 +00:00
//屏幕适配AutoSizehttps://github.com/JessYanCoding/AndroidAutoSize
implementation 'me.jessyan:autosize:1.2.1'
//友盟统计
2024-02-26 02:15:33 +00:00
implementation 'com.umeng.umsdk:common:9.6.7'
implementation 'com.umeng.umsdk:asms:1.8.2'
2023-01-20 03:10:08 +00:00
//预加载占位控件
implementation 'me.samlss:broccoli:1.0.0'
//RichTexthttps://github.com/zzhoujay/RichText
implementation 'com.zzhoujay.richtext:richtext:3.0.8'
//美团多渠道打包
//implementation 'com.meituan.android.walle:library:1.1.6'
2023-10-20 07:22:02 +00:00
def work_version = '2.8.1'
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
api("androidx.work:work-multiprocess:$work_version")
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
api("androidx.work:work-runtime-ktx:$work_version")
2023-01-20 03:10:08 +00:00
//Android Room
2023-10-20 07:22:02 +00:00
def room_version = '2.5.2'
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-20 03:10:08 +00:00
implementation "androidx.room:room-ktx:$room_version"
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-20 03:10:08 +00:00
implementation "androidx.room:room-runtime:$room_version"
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-20 03:10:08 +00:00
implementation "androidx.room:room-paging:$room_version"
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-20 03:10:08 +00:00
implementation "androidx.room:room-rxjava2:$room_version"
2023-12-17 12:04:18 +00:00
//noinspection KaptUsageInsteadOfKsp
2023-01-20 03:10:08 +00:00
kapt "androidx.room:room-compiler:$room_version"
//CodeViewhttps://github.com/AmrDeveloper/CodeView
2024-02-26 02:15:33 +00:00
implementation 'io.github.amrdeveloper:codeview:1.3.9'
2023-01-20 03:10:08 +00:00
//LiveEventBushttps://github.com/JeremyLiao/LiveEventBus
implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0'
//MarkdownViewhttps://github.com/tiagohm/MarkdownView
implementation 'com.github.tiagohm.MarkdownView:library:0.19.0'
//implementation 'com.github.tiagohm.MarkdownView:emoji:0.19.0'
2023-01-20 03:10:08 +00:00
def retrofit2_version = '2.9.0'
implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit2_version"
def paging_version = "3.1.1"
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-20 03:10:08 +00:00
implementation "androidx.paging:paging-runtime-ktx:$paging_version"
// alternatively - without Android dependencies for tests
2023-12-17 12:04:18 +00:00
//noinspection GradleDependency
2023-01-20 03:10:08 +00:00
testImplementation "androidx.paging:paging-common-ktx:$paging_version"
//权限请求框架https://github.com/getActivity/XXPermissions
2024-01-29 12:14:37 +00:00
implementation 'com.github.getActivity:XXPermissions:18.6'
//语种切换框架https://github.com/getActivity/MultiLanguages
2024-01-29 12:14:37 +00:00
implementation 'com.github.getActivity:MultiLanguages:b47f7be' //9.3
2023-01-20 03:10:08 +00:00
def mail_version = '1.6.7'
implementation "com.sun.mail:android-mail:$mail_version"
implementation "com.sun.mail:android-activation:$mail_version"
//Android Keep Alive(安卓保活)Cactus 集成双进程前台服务JobScheduleronePix(一像素)WorkManager无声音乐
//https://github.com/gyf-dev/Cactus
implementation 'com.gyf.cactus:cactus:1.1.3-beta13'
//HTTP服务器https://github.com/yanzhenjie/AndServer
implementation 'cn.ppps.andserver:api:2.1.12'
kapt 'cn.ppps.andserver:processor:2.1.12'
2023-01-20 03:10:08 +00:00
//国密算法SM4 的JAVA实现(基于BC实现)
api 'org.bouncycastle:bcprov-jdk15on:1.70'
//Location 是一个通过 Android 自带的 LocationManager 来实现的定位功能https://github.com/jenly1314/Location
implementation 'com.github.pppscn:location:1.0.0'
2023-12-01 14:37:37 +00:00
//Partial implementation of Quartz Cron Java for Android: https://github.com/gatewayapps/crondroid
implementation 'gatewayapps.crondroid:crondroid:1.0.0'
//Java Parser For Cron Expressions: https://github.com/grahamar/cron-parser
implementation 'net.redhogs.cronparser:cron-parser-core:3.5'
//侧边栏菜单https://github.com/yarolegovich/SlidingRootNav
implementation 'com.yarolegovich:sliding-root-nav:1.1.1'
2023-01-20 03:10:08 +00:00
}
//自动添加X-Library依赖
apply from: 'x-library.gradle'
//walle多渠道打包
//apply from: 'multiple-channel.gradle'
//获取 commit ID
static def getGitCommitId() {
try {
return 'git rev-parse --short HEAD'.execute().text.trim()
} catch (Exception e) {
e.printStackTrace()
return ""
}
}