325 lines
11 KiB
Groovy
325 lines
11 KiB
Groovy
import io.gitlab.arturbosch.detekt.Detekt
|
|
|
|
import java.text.SimpleDateFormat
|
|
import java.util.regex.Matcher
|
|
import java.util.regex.Pattern
|
|
|
|
plugins {
|
|
id("com.android.application")
|
|
id("org.jetbrains.kotlin.android")
|
|
// id("org.jetbrains.kotlin.kapt")
|
|
id("org.jetbrains.kotlin.plugin.serialization")
|
|
id("com.google.devtools.ksp").version("1.8.0-1.0.9")
|
|
id("io.gitlab.arturbosch.detekt")
|
|
}
|
|
|
|
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
def keystoreProperties = new Properties()
|
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
|
|
android {
|
|
compileSdkVersion stCompileSdkVersion
|
|
buildToolsVersion stBuildToolsVersion
|
|
|
|
// exoPlayer 2.9.0 以降は Java 8 compiler support を要求する
|
|
compileOptions {
|
|
sourceCompatibility javaSourceCompatibility
|
|
targetCompatibility javaTargetCompatibility
|
|
coreLibraryDesugaringEnabled true
|
|
}
|
|
|
|
defaultConfig {
|
|
targetSdkVersion stTargetSdkVersion
|
|
minSdkVersion stMinSdkVersion
|
|
|
|
versionCode 525
|
|
versionName "5.525"
|
|
applicationId "jp.juggler.subwaytooter"
|
|
vectorDrawables.useSupportLibrary = true
|
|
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
}
|
|
|
|
buildFeatures {
|
|
viewBinding true
|
|
buildConfig true
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = kotlinJvmTarget
|
|
freeCompilerArgs += [
|
|
"-opt-in=kotlin.ExperimentalStdlibApi",
|
|
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
|
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
|
// "-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
|
// "-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
|
]
|
|
}
|
|
|
|
// kotlin 1.6.0にすると This version (1.0.5) of the Compose Compiler requires Kotlin version 1.5.31 but you appear to be using Kotlin version 1.6.0 which is not known to be compatible. と怒られる
|
|
// buildFeatures {
|
|
// compose true
|
|
// }
|
|
// composeOptions {
|
|
// kotlinCompilerExtensionVersion compose_version
|
|
// }
|
|
|
|
signingConfigs {
|
|
release {
|
|
storeFile file(keystoreProperties['storeFile'])
|
|
storePassword keystoreProperties['storePassword']
|
|
keyAlias keystoreProperties['keyAlias']
|
|
keyPassword keystoreProperties['keyPassword']
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
shrinkResources false
|
|
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
|
|
|
lintOptions {
|
|
disable "MissingTranslation"
|
|
}
|
|
signingConfig signingConfigs.release
|
|
}
|
|
debug {
|
|
}
|
|
}
|
|
|
|
// Specifies comma-separated list of flavor dimensions.
|
|
flavorDimensions "fcmType"
|
|
|
|
productFlavors {
|
|
nofcm {
|
|
dimension "fcmType"
|
|
versionNameSuffix "-noFcm"
|
|
applicationIdSuffix ".noFcm"
|
|
def scheme = "subwaytooternofcm"
|
|
manifestPlaceholders = [customScheme: scheme]
|
|
buildConfigField("String", "customScheme", "\"$scheme\"")
|
|
}
|
|
fcm {
|
|
dimension "fcmType"
|
|
def scheme = "subwaytooter"
|
|
manifestPlaceholders = [customScheme: scheme]
|
|
buildConfigField("String", "customScheme", "\"$scheme\"")
|
|
}
|
|
}
|
|
|
|
// https://github.com/tateisu/SubwayTooter/issues/229
|
|
// splits {
|
|
// abi {
|
|
// enable true
|
|
// reset()
|
|
// include "arm64-v8a", "x86", "x86_64"
|
|
// universalApk true
|
|
// }
|
|
// }
|
|
|
|
// Generate Signed APK のファイル名を変更
|
|
android.applicationVariants.all { variant ->
|
|
if (variant.buildType.name == "release") {
|
|
variant.outputs.all { output ->
|
|
// Rename APK
|
|
def versionCode = defaultConfig.versionCode
|
|
def versionName = defaultConfig.versionName
|
|
def flavor = variant.flavorName
|
|
// def abi = output.getFilter("ABI") ?: "all"
|
|
def date = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())
|
|
def branch = gitBranch()
|
|
outputFileName = "SubwayTooter-${branch}-${flavor}-${versionCode}-${versionName}-${date}.apk"
|
|
}
|
|
}
|
|
}
|
|
|
|
packagingOptions {
|
|
resources {
|
|
excludes += ["/META-INF/{AL2.0,LGPL2.1}", "META-INF/DEPENDENCIES"]
|
|
// https://github.com/Kotlin/kotlinx.coroutines/issues/1064
|
|
pickFirsts += ["META-INF/atomicfu.kotlin_module"]
|
|
}
|
|
}
|
|
|
|
useLibrary "android.test.base"
|
|
useLibrary "android.test.mock"
|
|
lint {
|
|
warning "DuplicatePlatformClasses"
|
|
}
|
|
namespace "jp.juggler.subwaytooter"
|
|
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(kotlinJvmToolchain)
|
|
}
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
|
kotlinOptions {
|
|
jvmTarget = kotlinJvmTarget
|
|
}
|
|
}
|
|
|
|
static def gitBranch() {
|
|
def branch = "(no branch)"
|
|
def proc = "git status".execute()
|
|
proc.in.eachLine { line ->
|
|
def matcher = line =~ /\AOn branch (\S+)/
|
|
if (matcher) branch = matcher.group(1)
|
|
}
|
|
proc.err.eachLine { line -> println line }
|
|
proc.waitFor()
|
|
branch
|
|
}
|
|
|
|
//kapt {
|
|
// useBuildCache = true
|
|
//}
|
|
|
|
dependencies {
|
|
// desugar_jdk_libs 2.0.0 は AGP 7.4.0-alpha10 以降を要求する
|
|
//noinspection GradleDependency
|
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibVersion"
|
|
|
|
implementation(project(":base"))
|
|
implementation project(":colorpicker")
|
|
implementation project(":emoji")
|
|
implementation project(":apng_android")
|
|
implementation project(":anko")
|
|
implementation fileTree(include: ["*.aar"], dir: "src/main/libs")
|
|
|
|
fcmImplementation "com.google.firebase:firebase-messaging:23.1.2"
|
|
fcmImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlinxCoroutinesVersion"
|
|
|
|
// implementation "org.conscrypt:conscrypt-android:$conscryptVersion"
|
|
api "org.conscrypt:conscrypt-android:$conscryptVersion"
|
|
implementation "com.github.UnifiedPush:android-connector:2.1.1"
|
|
implementation "jp.wasabeef:glide-transformations:4.3.0"
|
|
|
|
def apng4AndroidVersion = "2.24.0"
|
|
implementation "com.github.penfeizhou.android.animation:apng:$apng4AndroidVersion"
|
|
|
|
ksp "com.github.bumptech.glide:ksp:$glideVersion"
|
|
|
|
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
|
|
|
|
testImplementation(project(":base"))
|
|
androidTestImplementation(project(":base"))
|
|
|
|
androidTestApi "androidx.test.espresso:espresso-core:$androidxTestEspressoCoreVersion"
|
|
androidTestApi "androidx.test.ext:junit-ktx:1.1.5"
|
|
androidTestApi "androidx.test.ext:junit:$androidxTestExtJunitVersion"
|
|
androidTestApi "androidx.test.ext:truth:1.5.0"
|
|
androidTestApi "androidx.test:core-ktx:$testKtxVersion"
|
|
androidTestApi "androidx.test:core:$androidxTestVersion"
|
|
androidTestApi "androidx.test:runner:1.5.2"
|
|
androidTestApi "org.jetbrains.kotlin:kotlin-test"
|
|
androidTestApi "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion"
|
|
testApi "androidx.arch.core:core-testing:$archVersion"
|
|
testApi "junit:junit:$junitVersion"
|
|
testApi "org.jetbrains.kotlin:kotlin-test"
|
|
testApi "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion"
|
|
|
|
// To use android test orchestrator
|
|
androidTestUtil "androidx.test:orchestrator:1.4.2"
|
|
|
|
testApi("com.squareup.okhttp3:mockwebserver:$okhttpVersion") {
|
|
exclude group: "com.squareup.okio", module: "okio"
|
|
exclude group: "com.squareup.okhttp3", module: "okhttp"
|
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-common"
|
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib"
|
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk8"
|
|
}
|
|
androidTestApi("com.squareup.okhttp3:mockwebserver:$okhttpVersion") {
|
|
exclude group: "com.squareup.okio", module: "okio"
|
|
exclude group: "com.squareup.okhttp3", module: "okhttp"
|
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-common"
|
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib"
|
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk8"
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
def willApplyGoogleService() {
|
|
Gradle gradle = getGradle()
|
|
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
|
|
Matcher matcher
|
|
|
|
matcher = Pattern.compile(
|
|
"(assemble|generate|connected)Fcm",
|
|
).matcher(tskReqStr)
|
|
if (!matcher.find()) {
|
|
println "willApplyGoogleService=false. $tskReqStr"
|
|
return false
|
|
} else {
|
|
println "willApplyGoogleService=true. $tskReqStr"
|
|
return true
|
|
}
|
|
}
|
|
|
|
if (willApplyGoogleService()) apply plugin: "com.google.gms.google-services"
|
|
|
|
|
|
tasks.register("detektAll", Detekt) {
|
|
description = "Custom DETEKT build for all modules"
|
|
|
|
// activate all available (even unstable) rules.
|
|
allRules = false
|
|
|
|
// a way of suppressing issues before introducing detekt
|
|
// baseline = file("$rootDir/config/detekt/baseline.xml")
|
|
|
|
parallel = true
|
|
ignoreFailures = false
|
|
autoCorrect = false
|
|
|
|
// preconfigure defaults
|
|
buildUponDefaultConfig = true
|
|
|
|
def configFile = files("$rootDir/config/detekt/config.yml")
|
|
config.setFrom(configFile)
|
|
|
|
def baselineFile = file("$rootDir/config/detekt/baseline.xml")
|
|
if (baselineFile.isFile()) {
|
|
baseline.set(baselineFile)
|
|
}
|
|
|
|
source = files(
|
|
"$rootDir/anko/src",
|
|
"$rootDir/apng/src",
|
|
"$rootDir/apng_android/src",
|
|
"$rootDir/app/src",
|
|
"$rootDir/base/src",
|
|
"$rootDir/colorpicker/src",
|
|
"$rootDir/emoji/src",
|
|
"$rootDir/icon_material_symbols/src",
|
|
"$rootDir/sample_apng/src",
|
|
)
|
|
|
|
// def kotlinFiles = "**/*.kt"
|
|
// include(kotlinFiles)
|
|
|
|
def resourceFiles = "**/resources/**"
|
|
def buildFiles = "**/build/**"
|
|
exclude(resourceFiles, buildFiles)
|
|
reports {
|
|
html.enabled = true
|
|
xml.enabled = false
|
|
txt.enabled = false
|
|
|
|
xml.required.set(true)
|
|
xml.outputLocation = file("$buildDir/reports/detekt/st-${name}.xml")
|
|
html.required.set(true)
|
|
html.outputLocation = file("$buildDir/reports/detekt/st-${name}.html")
|
|
txt.required.set(true)
|
|
txt.outputLocation = file("$buildDir/reports/detekt/st-${name}.txt")
|
|
sarif.required.set(true)
|
|
sarif.outputLocation = file("$buildDir/reports/detekt/st-${name}.sarif")
|
|
}
|
|
}
|
|
|