2023-09-09 13:49:20 +02:00
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.serialization")
id("com.google.devtools.ksp")
id("io.gitlab.arturbosch.detekt")
}
2023-09-09 14:38:55 +02:00
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
2023-09-09 13:49:20 +02:00
val keystoreProperties = Properties().apply {
load(FileInputStream(keystorePropertiesFile))
}
android {
namespace = "jp.juggler.subwaytooter"
compileSdk = Vers.stCompileSdkVersion
buildToolsVersion = Vers.stBuildToolsVersion
defaultConfig {
targetSdk = Vers.stTargetSdkVersion
minSdk = Vers.stMinSdkVersion
2023-09-09 14:46:24 +02:00
versionCode = 540
versionName = "5.540"
2023-09-09 13:49:20 +02:00
applicationId = "jp.juggler.subwaytooter"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
viewBinding = true
}
// exoPlayer 2.9.0 以降は Java 8 compiler support を要求する
compileOptions {
sourceCompatibility = Vers.javaSourceCompatibility
targetCompatibility = Vers.javaTargetCompatibility
isCoreLibraryDesugaringEnabled = true
}
kotlinOptions {
jvmTarget = Vers.kotlinJvmTarget
freeCompilerArgs = listOf(
"-opt-in=kotlin.ExperimentalStdlibApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=androidx.media3.common.util.UnstableApi",
// "-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 {
create("release") {
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}
buildTypes {
release {
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("release")
}
debug {
}
}
// Specifies comma-separated list of flavor dimensions.
flavorDimensions += "fcmType"
productFlavors {
create("nofcm") {
dimension = "fcmType"
versionNameSuffix = "-noFcm"
applicationIdSuffix = ".noFcm"
manifestPlaceholders["customScheme"] = "subwaytooternofcm"
}
create("fcm") {
dimension = "fcmType"
manifestPlaceholders["customScheme"] = "subwaytooter"
}
}
// https://github.com/tateisu/SubwayTooter/issues/229
// splits {
// abi {
// enable true
// reset()
// include "arm64-v8a", "x86", "x86_64"
// universalApk true
// }
// }
2023-09-09 14:38:55 +02:00
packaging {
2023-09-09 13:49:20 +02:00
resources {
excludes.addAll(
listOf(
"/META-INF/{AL2.0,LGPL2.1}",
"META-INF/DEPENDENCIES",
)
)
// https://github.com/Kotlin/kotlinx.coroutines/issues/1064
pickFirsts.addAll(
listOf(
"META-INF/atomicfu.kotlin_module",
)
)
}
}
useLibrary("android.test.base")
useLibrary("android.test.mock")
lint {
warning += "DuplicatePlatformClasses"
2023-09-09 14:38:55 +02:00
disable += "MissingTranslation"
2023-09-09 13:49:20 +02:00
}
kotlin {
jvmToolchain(Vers.kotlinJvmToolchain)
}
kotlinOptions {
jvmTarget = Vers.kotlinJvmTarget
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = Vers.kotlinJvmTarget
}
}
}
dependencies {
// desugar_jdk_libs 2.0.0 は AGP 7.4.0-alpha10 以降を要求する
//noinspection GradleDependency
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:${Vers.desugarLibVersion}")
implementation(project(":base"))
implementation(project(":colorpicker"))
implementation(project(":emoji"))
implementation(project(":apng_android"))
implementation(project(":anko"))
implementation(fileTree(mapOf("dir" to "src/main/libs", "include" to arrayOf("*.aar"))))
"fcmImplementation"("com.google.firebase:firebase-messaging:23.2.1")
"fcmImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:${Vers.kotlinxCoroutinesVersion}")
// implementation "org.conscrypt:conscrypt-android:$conscryptVersion"
api("org.conscrypt:conscrypt-android:${Vers.conscryptVersion}")
implementation("com.github.UnifiedPush:android-connector:2.1.1")
implementation("jp.wasabeef:glide-transformations:4.3.0")
implementation("com.github.androidmads:QRGenerator:1.0.1")
val apng4AndroidVersion = "2.25.0"
implementation("com.github.penfeizhou.android.animation:apng:$apng4AndroidVersion")
ksp("com.github.bumptech.glide:ksp:${Vers.glideVersion}")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${Vers.detektVersion}")
testImplementation(project(":base"))
androidTestImplementation(project(":base"))
androidTestApi("androidx.test.espresso:espresso-core:${Vers.androidxTestEspressoCoreVersion}")
androidTestApi("androidx.test.ext:junit-ktx:1.1.5")
androidTestApi("androidx.test.ext:junit:${Vers.androidxTestExtJunitVersion}")
androidTestApi("androidx.test.ext:truth:1.5.0")
androidTestApi("androidx.test:core-ktx:${Vers.testKtxVersion}")
androidTestApi("androidx.test:core:${Vers.androidxTestVersion}")
androidTestApi("androidx.test:runner:1.5.2")
androidTestApi("org.jetbrains.kotlin:kotlin-test:${Vers.kotlinTestVersion}")
androidTestApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Vers.kotlinxCoroutinesVersion}")
testApi("androidx.arch.core:core-testing:${Vers.archVersion}")
testApi("junit:junit:${Vers.junitVersion}")
testApi("org.jetbrains.kotlin:kotlin-test:${Vers.kotlinTestVersion}")
testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Vers.kotlinxCoroutinesVersion}")
// To use android test orchestrator
androidTestUtil("androidx.test:orchestrator:1.4.2")
testApi("com.squareup.okhttp3:mockwebserver:${Vers.okhttpVersion}") {
exclude("com.squareup.okio", "okio")
exclude("com.squareup.okhttp3", "okhttp")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-common")
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
androidTestApi("com.squareup.okhttp3:mockwebserver:${Vers.okhttpVersion}") {
exclude("com.squareup.okio", "okio")
exclude("com.squareup.okhttp3", "okhttp")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-common")
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
}
repositories {
mavenCentral()
}
fun willApplyGoogleService(): Boolean {
2023-09-09 14:38:55 +02:00
val taskRequestsString = gradle.startParameter.taskRequests.toString()
2023-09-09 13:49:20 +02:00
val isMatch = """(assemble|generate|connected)Fcm""".toRegex()
.find(taskRequestsString) != null
println("willApplyGoogleService=$isMatch. $taskRequestsString")
return isMatch
}
if (willApplyGoogleService()) apply(plugin = "com.google.gms.google-services")
tasks.register<Detekt>("detektAll") {
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
val configFile = files("$rootDir/config/detekt/config.yml")
config.setFrom(configFile)
val baselineFile = file("$rootDir/config/detekt/baseline.xml")
2023-09-09 14:38:55 +02:00
if (baselineFile.isFile) {
2023-09-09 13:49:20 +02:00
baseline.set(baselineFile)
}
setSource(
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",
)
)
// val kotlinFiles = "**/*.kt"
// include(kotlinFiles)
val resourceFiles = "**/resources/**"
val buildFiles = "**/build/**"
exclude(resourceFiles, buildFiles)
reports {
2023-09-09 14:38:55 +02:00
xml.required.set(false)
2023-09-09 13:49:20 +02:00
xml.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.xml"))
2023-09-09 14:38:55 +02:00
2023-09-09 13:49:20 +02:00
html.required.set(true)
html.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.html"))
2023-09-09 14:38:55 +02:00
2023-09-09 13:49:20 +02:00
txt.required.set(true)
txt.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.txt"))
2023-09-09 14:38:55 +02:00
2023-09-09 13:49:20 +02:00
sarif.required.set(true)
sarif.outputLocation.set(file("$buildDir/reports/detekt/st-${name}.sarif"))
}
}