From 2799e75598a132a7b4c0ed6c67973661919d7a23 Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Mon, 22 Apr 2024 13:46:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:file=5Ffolder:=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=97=B6=E5=8A=A8=E6=80=81=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 3a2fcd4..cf77365 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,11 @@ plugins { id 'com.android.application' } +def static releaseTime() { + return new Date().format("yyyyMMdd_HHmmss", TimeZone.default) +} + + android { namespace 'cc.niushuai.dididone' compileSdk 34 @@ -10,9 +15,11 @@ android { applicationId "cc.niushuai.dididone" minSdk 24 targetSdk 32 - versionCode 1 + versionCode 12 versionName "1.2" + resValue "string", "weathericons_version", "${versionName}" + javaCompileOptions { annotationProcessorOptions { arguments += [ @@ -38,6 +45,19 @@ android { buildFeatures { viewBinding true } + + android.applicationVariants.all { + variant -> + variant.outputs.all { + //这里修改apk文件名 + outputFileName = "${getAppName()}_v${variant.versionName.replaceAll('\\s+', '_')}_${releaseTime()}_${variant.buildType.name}.apk" + } + } +} + +def getAppName() { + def stringsFile = android.sourceSets.main.res.sourceFiles.find { it.name.equals 'strings.xml' } + return new XmlParser().parse(stringsFile).string.find { it.@name.equals 'app_name' }.text() } dependencies {