SmsForwarder/app/build.gradle

189 lines
6.9 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

apply plugin: 'com.android.application'
def keyProps = new Properties()
def keyPropsFile = rootProject.file('keystore/keystore.properties')
if (keyPropsFile.exists()) {
keyProps.load(new FileInputStream(keyPropsFile))
}
// 读取version.properties
def versionProps = new Properties()
def versionPropsFile = rootProject.file('version.properties')
if (versionPropsFile.exists()) {
versionProps.load(new FileInputStream(versionPropsFile))
}
android {
//noinspection GradleDependency
buildToolsVersion '32.0.0'
compileSdkVersion 32
compileOptions {
sourceCompatibility 11
targetCompatibility 11
}
defaultConfig {
applicationId "com.idormy.sms.forwarder"
minSdkVersion 21
targetSdkVersion 32
versionCode versionProps['versionCode'].toInteger()
versionName versionProps['versionName']
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
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 {
minifyEnabled false
//shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
//shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
//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 {
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']
}
}
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK.
variant.outputs.each {
output ->
def date = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08"))
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 = "SmsForwarder_${variant.name}_${versionName}_${output.versionCode}_${date}_${abiName}.apk"
}
}
lint {
checkReleaseBuilds false
}
}
task upgradeVersion {
group 'help'
description '构建新版本'
doLast {
println("---自动升级版本号---\n")
String oldVersionCode = versionProps['versionCode']
String oldVersionName = versionProps['versionName']
if (oldVersionCode == null || oldVersionName == null ||
oldVersionCode.isEmpty() || oldVersionName.isEmpty()) {
println("error:版本号不能为空")
return
}
versionProps['versionCode'] = String.valueOf(versionProps['versionCode'].toInteger() + 1)
String str = versionProps['versionName'].toString()
versionProps['versionName'] = str.substring(0, str.lastIndexOf('.') + 1) +
(str.substring(str.lastIndexOf('.') + 1).toInteger() + 1)
String tip =
"版本号从$oldVersionName($oldVersionCode)升级到${versionProps['versionName']}(${versionProps['versionCode']})"
println(tip)
def writer = new FileWriter(versionPropsFile)
versionProps.store(writer, null)
writer.flush()
writer.close()
def tag = "v${versionProps['versionName']}"
cmdExecute("git pull")
cmdExecute("git add version.properties")
cmdExecute("git commit -m \"版本号升级为:$tag\"")
cmdExecute("git push origin")
cmdExecute("git tag $tag")
cmdExecute("git push origin $tag")
}
}
void cmdExecute(String cmd) {
println "\n执行$cmd"
println cmd.execute().text
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleDependency
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.android.material:material:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//okhttp
//noinspection GradleDependency
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.squareup.okio:okio:3.0.0'
//fastjson
implementation "com.alibaba:fastjson:1.2.79"
//XUpdate
implementation 'com.github.xuexiangjys:XUpdate:2.1.1'
implementation 'com.github.xuexiangjys.XUpdateAPI:xupdate-easy:1.0.1'
implementation 'com.github.xuexiangjys.XUpdateAPI:xupdate-downloader-aria:1.0.1'
//EmailKit
implementation 'com.github.mailhu:emailkit:4.2.2'
implementation 'com.sun.mail:android-mail:1.6.7'
implementation 'com.sun.mail:android-activation:1.6.7'
//Lombok
//noinspection AnnotationProcessorOnCompilePath
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
//RxJava
//implementation 'io.reactivex.rxjava3:rxjava:3.1.3'
//AndroidAsync
implementation 'com.koushikdutta.async:androidasync:3.1.0'
//吐司框架https://github.com/getActivity/ToastUtils
implementation 'com.github.getActivity:ToastUtils:10.3'
//权限请求框架https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:13.2'
//jetty
implementation "org.eclipse.jetty:jetty-server:9.2.30.v20200428"
implementation "org.eclipse.jetty:jetty-servlet:9.2.30.v20200428"
//友盟统计SDK
implementation 'com.umeng.umsdk:common:9.4.7'// (必选)
implementation 'com.umeng.umsdk:asms:1.6.0'// 必选
}