2022-03-13 00:50:37 +09:00
import io.gitlab.arturbosch.detekt.Detekt
2017-04-23 14:42:09 +09:00
import java.text.SimpleDateFormat
2023-02-05 05:52:26 +09:00
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" )
}
2017-04-21 01:23:59 +09:00
2023-02-09 04:50:08 +09:00
def keystorePropertiesFile = rootProject . file ( "keystore.properties" )
def keystoreProperties = new Properties ( )
keystoreProperties . load ( new FileInputStream ( keystorePropertiesFile ) )
2017-04-21 01:23:59 +09:00
android {
2023-02-02 01:11:39 +09:00
compileSdkVersion stCompileSdkVersion
buildToolsVersion stBuildToolsVersion
2018-09-12 14:55:15 +09:00
2019-08-01 03:30:56 +09:00
// exoPlayer 2.9.0 以降は Java 8 compiler support を要求する
2019-07-12 13:38:19 +09:00
compileOptions {
2020-09-09 05:17:32 +09:00
sourceCompatibility JavaVersion . VERSION_1_8
2019-07-12 13:38:19 +09:00
targetCompatibility JavaVersion . VERSION_1_8
2022-11-07 11:45:17 +09:00
coreLibraryDesugaringEnabled true
2019-07-12 13:38:19 +09:00
}
2017-04-21 01:23:59 +09:00
defaultConfig {
2023-02-02 01:11:39 +09:00
targetSdkVersion stTargetSdkVersion
minSdkVersion stMinSdkVersion
2018-01-15 06:47:42 +09:00
2023-02-22 04:27:52 +09:00
versionCode 521
versionName "5.521"
2018-09-12 14:55:15 +09:00
applicationId "jp.juggler.subwaytooter"
2021-11-06 12:00:29 +09:00
vectorDrawables . useSupportLibrary = true
2023-01-17 21:42:47 +09:00
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2017-04-21 01:23:59 +09:00
}
2017-04-25 23:47:27 +09:00
2021-11-07 05:36:59 +09:00
viewBinding {
enabled = true
}
2021-05-27 11:15:59 +09:00
kotlinOptions {
2023-02-02 01:11:39 +09:00
jvmTarget = kotlinJvmTarget
2021-05-27 11:15:59 +09:00
freeCompilerArgs + = [
2022-05-29 22:38:21 +09:00
"-opt-in=kotlin.ExperimentalStdlibApi" ,
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" ,
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi" ,
2022-05-29 14:00:51 +09:00
// "-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
// "-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
2021-05-27 11:15:59 +09:00
]
}
2021-11-20 09:36:43 +09:00
// 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
// }
2022-05-29 14:00:51 +09:00
// composeOptions {
// kotlinCompilerExtensionVersion compose_version
// }
2021-05-22 07:03:16 +09:00
2023-02-09 04:50:08 +09:00
signingConfigs {
release {
storeFile file ( keystoreProperties [ 'storeFile' ] )
storePassword keystoreProperties [ 'storePassword' ]
keyAlias keystoreProperties [ 'keyAlias' ]
keyPassword keystoreProperties [ 'keyPassword' ]
}
}
2017-04-21 01:23:59 +09:00
buildTypes {
release {
2023-02-05 05:52:26 +09:00
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile ( "proguard-android.txt" ) , "proguard-rules.pro"
2018-08-31 22:22:51 +09:00
lintOptions {
2023-02-05 05:52:26 +09:00
disable "MissingTranslation"
2018-08-31 22:22:51 +09:00
}
2023-02-09 04:50:08 +09:00
signingConfig signingConfigs . release
2017-04-21 01:23:59 +09:00
}
2023-02-05 05:52:26 +09:00
debug {
2023-02-02 03:07:26 +09:00
}
2017-04-21 01:23:59 +09:00
}
2017-04-25 23:47:27 +09:00
2017-11-04 23:51:15 +09:00
// Specifies comma-separated list of flavor dimensions.
2023-02-05 05:52:26 +09:00
flavorDimensions "fcmType"
2017-11-04 23:51:15 +09:00
2017-04-23 14:42:09 +09:00
productFlavors {
2023-02-05 05:52:26 +09:00
nofcm {
dimension "fcmType"
versionNameSuffix "-noFcm"
2023-02-09 04:50:08 +09:00
applicationIdSuffix ".noFcm"
def scheme = "subwaytooternofcm"
manifestPlaceholders = [ customScheme: scheme ]
buildConfigField ( "String" , "customScheme" , "\"$scheme\"" )
2023-02-05 05:52:26 +09:00
}
fcm {
dimension "fcmType"
2023-02-09 04:50:08 +09:00
def scheme = "subwaytooter"
manifestPlaceholders = [ customScheme: scheme ]
buildConfigField ( "String" , "customScheme" , "\"$scheme\"" )
2017-04-23 14:42:09 +09:00
}
}
2023-02-11 21:51:19 +09:00
// https://github.com/tateisu/SubwayTooter/issues/229
// splits {
// abi {
// enable true
// reset()
// include "arm64-v8a", "x86", "x86_64"
// universalApk true
// }
// }
2017-04-23 14:42:09 +09:00
// Generate Signed APK のファイル名を変更
2017-11-04 23:51:15 +09:00
android . applicationVariants . all { variant - >
2017-04-23 14:42:09 +09:00
if ( variant . buildType . name = = "release" ) {
2023-02-11 21:51:19 +09:00
variant . outputs . all { output - >
2017-11-04 23:51:15 +09:00
// Rename APK
def versionCode = defaultConfig . versionCode
def versionName = defaultConfig . versionName
def flavor = variant . flavorName
2023-02-11 21:51:19 +09:00
// def abi = output.getFilter("ABI") ?: "all"
2017-11-04 23:51:15 +09:00
def date = new SimpleDateFormat ( "yyyyMMdd_HHmmss" ) . format ( new Date ( ) )
2021-10-28 05:58:19 +09:00
def branch = gitBranch ( )
outputFileName = "../../SubwayTooter-${branch}-${flavor}-${versionCode}-${versionName}-${date}.apk"
2017-04-23 14:42:09 +09:00
}
}
}
2017-11-04 23:51:15 +09:00
2019-04-13 08:12:17 +09:00
packagingOptions {
2021-10-28 05:58:19 +09:00
resources {
2023-02-05 05:52:26 +09:00
excludes + = [ "/META-INF/{AL2.0,LGPL2.1}" , "META-INF/DEPENDENCIES" ]
2023-01-27 00:54:04 +09:00
// https://github.com/Kotlin/kotlinx.coroutines/issues/1064
2023-02-05 05:52:26 +09:00
pickFirsts + = [ "META-INF/atomicfu.kotlin_module" ]
2021-10-28 05:58:19 +09:00
}
2019-04-13 08:12:17 +09:00
}
2019-08-30 13:02:08 +09:00
2023-02-05 05:52:26 +09:00
useLibrary "android.test.base"
useLibrary "android.test.mock"
2023-01-27 00:54:04 +09:00
lint {
2023-02-05 05:52:26 +09:00
warning "DuplicatePlatformClasses"
2022-03-14 09:16:44 +09:00
}
2023-02-05 05:52:26 +09:00
namespace "jp.juggler.subwaytooter"
2023-01-27 00:54:04 +09:00
2017-04-21 01:23:59 +09:00
}
2021-10-28 05:58:19 +09:00
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
}
2019-01-25 23:38:21 +09:00
kapt {
useBuildCache = true
}
2017-04-21 01:23:59 +09:00
dependencies {
2022-11-07 11:45:17 +09:00
// desugar_jdk_libs 2.0.0 は AGP 7.4.0-alpha10 以降を要求する
//noinspection GradleDependency
2023-02-02 01:11:39 +09:00
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibVersion"
2022-11-07 11:45:17 +09:00
2023-01-14 20:20:24 +09:00
implementation ( project ( ":base" ) )
2023-02-05 05:52:26 +09:00
implementation project ( ":colorpicker" )
implementation project ( ":emoji" )
implementation project ( ":apng_android" )
implementation project ( ":anko" )
implementation fileTree ( include: [ "*.aar" ] , dir: "src/main/libs" )
2018-01-05 03:52:25 +09:00
2023-02-06 11:10:24 +09:00
fcmImplementation "com.google.firebase:firebase-messaging:23.1.1"
2023-02-10 13:57:07 +09:00
fcmImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlinxCoroutinesVersion"
2023-02-06 11:10:24 +09:00
2023-02-02 03:07:26 +09:00
// implementation "org.conscrypt:conscrypt-android:$conscryptVersion"
api "org.conscrypt:conscrypt-android:$conscryptVersion"
2023-02-05 05:52:26 +09:00
implementation "com.github.UnifiedPush:android-connector:2.1.1"
2023-02-10 07:34:40 +09:00
implementation "jp.wasabeef:glide-transformations:4.3.0"
def apng4AndroidVersion = "2.24.0"
implementation "com.github.penfeizhou.android.animation:apng:$apng4AndroidVersion"
2022-06-14 02:23:46 +09:00
2023-02-02 01:11:39 +09:00
kapt "androidx.annotation:annotation:$androidxAnnotationVersion"
2023-02-05 05:52:26 +09:00
//kapt "com.github.bumptech.glide:compiler:$glideVersion"
ksp "com.github.bumptech.glide:ksp:$glideVersion"
2023-01-14 19:19:01 +09:00
2023-02-02 01:11:39 +09:00
detektPlugins ( "io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion" )
2023-01-15 16:51:13 +09:00
testImplementation ( project ( ":base" ) )
androidTestImplementation ( project ( ":base" ) )
2023-02-02 01:11:39 +09:00
androidTestApi "androidx.test.espresso:espresso-core:$androidxTestEspressoCoreVersion"
2023-01-15 16:51:13 +09:00
androidTestApi "androidx.test.ext:junit-ktx:1.1.5"
2023-02-02 01:11:39 +09:00
androidTestApi "androidx.test.ext:junit:$androidxTestExtJunitVersion"
2023-01-15 16:51:13 +09:00
androidTestApi "androidx.test.ext:truth:1.5.0"
2023-02-02 01:11:39 +09:00
androidTestApi "androidx.test:core-ktx:$testKtxVersion"
androidTestApi "androidx.test:core:$androidxTestVersion"
2023-01-15 16:51:13 +09:00
androidTestApi "androidx.test:runner:1.5.2"
androidTestApi "org.jetbrains.kotlin:kotlin-test"
2023-02-02 01:11:39 +09:00
androidTestApi "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion"
testApi "androidx.arch.core:core-testing:$archVersion"
testApi "junit:junit:$junitVersion"
2023-01-17 21:42:47 +09:00
testApi "org.jetbrains.kotlin:kotlin-test"
2023-02-02 01:11:39 +09:00
testApi "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion"
2023-01-15 16:51:13 +09:00
// 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"
}
2017-04-21 01:23:59 +09:00
}
2017-05-24 18:20:56 +09:00
2017-11-04 23:51:15 +09:00
repositories {
mavenCentral ( )
}
2017-12-22 21:59:52 +09:00
2023-02-05 05:52:26 +09:00
def willApplyGoogleService ( ) {
Gradle gradle = getGradle ( )
String tskReqStr = gradle . getStartParameter ( ) . getTaskRequests ( ) . toString ( )
Matcher matcher
2023-02-06 00:44:28 +09:00
matcher = Pattern . compile (
"(assemble|generate|connected)Fcm" ,
) . matcher ( tskReqStr )
2023-02-05 05:52:26 +09:00
if ( ! matcher . find ( ) ) {
println "willApplyGoogleService=false. $tskReqStr"
return false
2023-02-06 11:10:24 +09:00
} else {
2023-02-05 05:52:26 +09:00
println "willApplyGoogleService=true. $tskReqStr"
return true
}
}
if ( willApplyGoogleService ( ) ) apply plugin: "com.google.gms.google-services"
2021-06-20 12:02:30 +09:00
2023-01-14 19:19:01 +09:00
tasks . register ( "detektAll" , Detekt ) {
description = "Custom DETEKT build for all modules"
2021-06-20 12:02:30 +09:00
// activate all available (even unstable) rules.
allRules = false
// a way of suppressing issues before introducing detekt
2022-03-11 08:18:41 +09:00
// baseline = file("$rootDir/config/detekt/baseline.xml")
2021-06-20 12:02:30 +09:00
2023-01-14 19:19:01 +09:00
parallel = true
ignoreFailures = false
autoCorrect = false
2021-06-20 12:02:30 +09:00
2023-01-14 19:19:01 +09:00
// preconfigure defaults
buildUponDefaultConfig = true
2023-01-15 16:51:13 +09:00
def configFile = files ( "$rootDir/config/detekt/config.yml" )
2023-01-14 19:19:01 +09:00
config . setFrom ( configFile )
2023-01-15 16:51:13 +09:00
def baselineFile = file ( "$rootDir/config/detekt/baseline.xml" )
2023-01-14 19:19:01 +09:00
if ( baselineFile . isFile ( ) ) {
baseline . set ( baselineFile )
}
2023-01-15 16:51:13 +09:00
source = files (
2023-02-02 01:11:39 +09:00
"$rootDir/anko/src" ,
2023-01-15 16:51:13 +09:00
"$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/**"
2023-01-14 19:19:01 +09:00
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" )
2021-06-20 12:02:30 +09:00
}
}
2023-02-05 05:52:26 +09:00