SIGN IN SIGN UP
Blankj / AndroidUtilCode UNCLAIMED

:fire: Android developers should collect the following utils(updating).

2021-12-06 00:00:20 +08:00
apply plugin: "com.android.application"
2019-05-29 22:19:17 +08:00
apply {
from "${rootDir.path}/buildCommon.gradle"
from "${rootDir.path}/config/flavor.gradle"
2021-12-06 00:00:20 +08:00
if (Config.plugins.plugin_api.isApply) {
plugin Config.plugins.plugin_api.id
2019-07-10 19:46:10 +08:00
}
2021-12-06 00:00:20 +08:00
if (Config.plugins.plugin_bus.isApply) {
plugin Config.plugins.plugin_bus.id
2020-01-20 18:24:34 +08:00
}
2019-05-29 22:19:17 +08:00
}
2019-07-10 19:46:10 +08:00
configSigning()
configApkName()
2019-05-29 22:19:17 +08:00
2021-12-06 00:00:20 +08:00
//if (PluginConfig.plugin_bus.isApply) {
// bus {
// onlyScanLibRegex = '^([:]|(com\\.blankj)).+$'
// }
//}
//
//if (PluginConfig.plugin_api.isApply) {
// api {
// onlyScanLibRegex = '^([:]|(com\\.blankj)).+$'
// }
//}
2019-11-07 01:54:43 +08:00
2019-05-29 22:19:17 +08:00
android {
defaultConfig {
2019-07-10 19:46:10 +08:00
applicationId Config.applicationId + suffix
targetSdkVersion Config.targetSdkVersion
2019-05-29 22:19:17 +08:00
multiDexEnabled true
}
buildTypes {
debug {}
2019-08-09 01:15:51 +08:00
2019-05-29 22:19:17 +08:00
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/*'
}
dexOptions {
2019-06-03 21:13:11 +08:00
preDexLibraries true
2019-05-29 22:19:17 +08:00
javaMaxHeapSize "8g"
maxProcessCount 8
2019-06-03 21:13:11 +08:00
dexInProcess = true
2019-05-29 22:19:17 +08:00
}
productFlavors {
dev {
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
resValue "string", "app_name", Config.appName + suffix + "-dev"
}
production {
resValue "string", "app_name", Config.appName + suffix
}
}
}
2019-05-29 22:19:17 +08:00
dependencies {
// LeakCanary
2021-12-06 00:00:20 +08:00
debugImplementation Config.libs.leakcanary.path
2019-07-10 19:46:10 +08:00
2021-12-06 00:00:20 +08:00
debugImplementation Config.modules.lib_utildebug.dep
releaseImplementation Config.modules.lib_utildebug_no_op.dep
2019-07-26 16:58:16 +08:00
2019-07-13 20:51:18 +08:00
// 根据 Config.pkgConfig 来依赖所有 pkg
for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) {
api entrySet.value.dep
}
2021-12-06 00:00:20 +08:00
if (Config.modules.feature_mock.isApply) {
api ModuleConfig.modules.feature_mock.dep
2019-07-10 19:46:10 +08:00
}
2019-05-29 22:19:17 +08:00
}
2019-07-10 19:46:10 +08:00
def getSuffix() {
2020-03-26 01:01:36 +08:00
if (project.name == "feature_launcher_app") return ""
return "." + project.
name.
substring("feature_".length(), project.name.length() - "_app".length())
2019-05-29 22:19:17 +08:00
}
2019-07-10 19:46:10 +08:00
def configSigning() {
2019-05-29 22:19:17 +08:00
File signPropertiesFile = file("${rootDir.path}/sign/keystore.properties")
if (!signPropertiesFile.exists()) return
2019-07-14 18:25:56 +08:00
GLog.d("${project.toString()} sign start...")
2019-07-10 19:46:10 +08:00
project.android {
2019-05-29 22:19:17 +08:00
Properties properties = new Properties()
properties.load(new FileInputStream(signPropertiesFile))
signingConfigs {
release {
storeFile new File(signPropertiesFile.getParent(), properties['keystore'])
storePassword properties['storePassword']
keyAlias properties['keyAlias']
keyPassword properties['keyPassword']
}
}
buildTypes.release.signingConfig signingConfigs.release
}
2019-07-14 18:25:56 +08:00
GLog.d("${project.toString()} sign end...")
2019-05-29 22:19:17 +08:00
}
2019-07-10 19:46:10 +08:00
def configApkName() {
project.android.applicationVariants.all { variant ->
2019-05-29 22:19:17 +08:00
if (variant.buildType.name != "debug") {
2019-06-28 13:20:00 +08:00
def artifact = variant.getPackageApplicationProvider().get()
artifact.outputDirectory = new File("${rootDir.path}/apk")
variant.outputs.each {
it.outputFileName = "util" + suffix +
(variant.flavorName == "" ? "" : ("_" + variant.flavorName)) +
"_" +
variant.versionName.replace(".", "_") +
"_" +
variant.buildType.name +
".apk"
2019-05-29 22:19:17 +08:00
}
}
}
}