APKのファイル名変更をapp/build.gradle.ktsからapkGen.plに移動
This commit is contained in:
parent
2ae268b2aa
commit
0685915eea
57
apkGen.pl
57
apkGen.pl
|
@ -22,6 +22,59 @@ cmd "./gradlew assembleNoFcmRelease";
|
|||
cmd "./gradlew assembleFcmRelease";
|
||||
cmd "./gradlew --stop";
|
||||
|
||||
|
||||
sub getBranch{
|
||||
my $text = `git rev-parse --abbrev-ref HEAD`;
|
||||
$text =~ s/\A\s+//;
|
||||
$text =~ s/\s+\z//;
|
||||
return $text;
|
||||
}
|
||||
|
||||
sub getDate{
|
||||
my @lt= localtime;
|
||||
$lt[4]+=1;$lt[5]+=1900;
|
||||
return sprintf("%d%02d%02d_%02d%02d%02d",reverse @lt[0..5]);
|
||||
}
|
||||
|
||||
sub getVersion{
|
||||
my $appBuildGradle = "app/build.gradle.kts";
|
||||
my($code,$name);
|
||||
open(my $fh,"<",$appBuildGradle) or die "$! $appBuildGradle";
|
||||
while(<$fh>){
|
||||
s/[\x0d\x0a]+//g;
|
||||
s|//.*| |;
|
||||
if(/versionCode\s*=\s*(\S+)/){
|
||||
my $a = $1;
|
||||
$a =~ s/[\s"]+//g;
|
||||
$code = $a;
|
||||
}elsif( /versionName\s*=\s*(\S+)/ ){
|
||||
my $a = $1;
|
||||
$a =~ s/[\s"]+//g;
|
||||
$name = $a;
|
||||
}
|
||||
}
|
||||
close($fh) or die "$! $appBuildGradle";
|
||||
$code or die "missing versionCode in $appBuildGradle";
|
||||
$name or die "missing versionCode in $appBuildGradle";
|
||||
return ($code,$name);
|
||||
}
|
||||
|
||||
my ($versionCode,$versionName) = getVersion();
|
||||
my $branch = getBranch() or die "missing git branch";
|
||||
my $date = getDate() or die "missing date";
|
||||
|
||||
cmd "mkdir -p _apk";
|
||||
cmd "mv `find app/build/outputs/apk/ -path '*.apk'` _apk/";
|
||||
cmd "ls -1t _apk/SubwayTooter*.apk |head -n 5";
|
||||
|
||||
for(
|
||||
["fcm","app/build/outputs/apk/fcm/release/app-fcm-release.apk"],
|
||||
["noFcm","app/build/outputs/apk/nofcm/release/app-nofcm-release.apk"],
|
||||
){
|
||||
my($flavor,$srcPath)=@$_;
|
||||
(-f $srcPath) or die "not found: $srcPath";
|
||||
|
||||
my $dstName= "SubwayTooter-$branch-$flavor-$versionCode-$versionName-$date.apk";
|
||||
|
||||
cmd "mv $srcPath _apk/$dstName";
|
||||
}
|
||||
|
||||
cmd "ls -lt _apk/SubwayTooter*.apk |head -n 2";
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
|
||||
import com.android.build.gradle.api.ApplicationVariant
|
||||
import com.android.build.gradle.api.BaseVariantOutput
|
||||
|
||||
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
|
||||
import io.gitlab.arturbosch.detekt.Detekt
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.io.FileInputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
|
@ -18,7 +11,7 @@ plugins {
|
|||
id("io.gitlab.arturbosch.detekt")
|
||||
}
|
||||
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties().apply {
|
||||
load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
@ -89,10 +82,6 @@ android {
|
|||
getDefaultProguardFile("proguard-android.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
|
||||
lintOptions {
|
||||
disable("MissingTranslation")
|
||||
}
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
debug {
|
||||
|
@ -125,43 +114,7 @@ android {
|
|||
// }
|
||||
// }
|
||||
|
||||
// Generate Signed APK のファイル名を変更
|
||||
applicationVariants.all(object : Action<ApplicationVariant> {
|
||||
override fun execute(variant: ApplicationVariant) {
|
||||
println("variant: ${variant}")
|
||||
|
||||
// Rename APK
|
||||
val versionCode = defaultConfig.versionCode
|
||||
val versionName = defaultConfig.versionName
|
||||
val flavor = variant.flavorName
|
||||
// val abi = output.getFilter("ABI") ?: "all"
|
||||
val date = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
|
||||
val branch = providers.exec {
|
||||
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||
}.standardOutput.asText.get()?.trim() ?: "(no branch)"
|
||||
|
||||
variant.outputs.all(object : Action<BaseVariantOutput> {
|
||||
override fun execute(output: BaseVariantOutput) {
|
||||
val outputImpl = output as BaseVariantOutputImpl
|
||||
outputImpl.outputFileName =
|
||||
"SubwayTooter-${branch}-${flavor}-${versionCode}-${versionName}-${date}.apk"
|
||||
println("output file name: ${outputImpl.outputFileName}")
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
if (variant.buildType.name == "release") {
|
||||
variant.outputs.all { output ->
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
packaging {
|
||||
resources {
|
||||
excludes.addAll(
|
||||
listOf(
|
||||
|
@ -182,6 +135,7 @@ android {
|
|||
useLibrary("android.test.mock")
|
||||
lint {
|
||||
warning += "DuplicatePlatformClasses"
|
||||
disable += "MissingTranslation"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
@ -269,8 +223,7 @@ repositories {
|
|||
}
|
||||
|
||||
fun willApplyGoogleService(): Boolean {
|
||||
val gradle = getGradle()
|
||||
val taskRequestsString = gradle.getStartParameter().getTaskRequests().toString()
|
||||
val taskRequestsString = gradle.startParameter.taskRequests.toString()
|
||||
|
||||
val isMatch = """(assemble|generate|connected)Fcm""".toRegex()
|
||||
.find(taskRequestsString) != null
|
||||
|
@ -302,7 +255,7 @@ tasks.register<Detekt>("detektAll") {
|
|||
config.setFrom(configFile)
|
||||
|
||||
val baselineFile = file("$rootDir/config/detekt/baseline.xml")
|
||||
if (baselineFile.isFile()) {
|
||||
if (baselineFile.isFile) {
|
||||
baseline.set(baselineFile)
|
||||
}
|
||||
|
||||
|
@ -327,16 +280,15 @@ tasks.register<Detekt>("detektAll") {
|
|||
val buildFiles = "**/build/**"
|
||||
exclude(resourceFiles, buildFiles)
|
||||
reports {
|
||||
html.enabled = true
|
||||
xml.enabled = false
|
||||
txt.enabled = false
|
||||
|
||||
xml.required.set(true)
|
||||
xml.required.set(false)
|
||||
xml.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.xml"))
|
||||
|
||||
html.required.set(true)
|
||||
html.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.html"))
|
||||
|
||||
txt.required.set(true)
|
||||
txt.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.txt"))
|
||||
|
||||
sarif.required.set(true)
|
||||
sarif.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.sarif"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue