Browse Source

feat: 📁 构建时动态文件名

master
niushuai233 1 year ago
parent
commit
2799e75598
  1. 22
      app/build.gradle

22
app/build.gradle

@ -2,6 +2,11 @@ plugins { @@ -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 { @@ -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 { @@ -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 {

Loading…
Cancel
Save