Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ktlint 1.0.1 and tweak code style #1590

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 2 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ root = true

[*]
charset = utf-8
indent_size = 4
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt,kts}]
ij_kotlin_imports_layout = *
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_code_style = intellij_idea
ktlint_standard_discouraged-comment-location = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_property-naming = disabled

[*.{yml,yaml}]
indent_size = 2
ktlint_function_naming_ignore_when_annotated_with = Composable
276 changes: 138 additions & 138 deletions android-app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


plugins {
id("app.tivi.android.application")
id("app.tivi.kotlin.android")
id("app.tivi.compose")
id("app.tivi.android.application")
id("app.tivi.kotlin.android")
id("app.tivi.compose")
}

val appVersionCode = properties["TIVI_VERSIONCODE"]?.toString()?.toInt() ?: 1000
Expand All @@ -14,172 +14,172 @@ println("APK version code: $appVersionCode")
val useReleaseKeystore = rootProject.file("release/app-release.jks").exists()

android {
namespace = "app.tivi"

defaultConfig {
applicationId = "app.tivi"
versionCode = appVersionCode
versionName = "0.9.8"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
namespace = "app.tivi"

defaultConfig {
applicationId = "app.tivi"
versionCode = appVersionCode
versionName = "0.9.8"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("release/app-debug.jks")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("release/app-debug.jks")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}

create("release") {
if (useReleaseKeystore) {
storeFile = rootProject.file("release/app-release.jks")
storePassword = properties["TIVI_RELEASE_KEYSTORE_PWD"]?.toString() ?: ""
keyAlias = "tivi"
keyPassword = properties["TIVI_RELEASE_KEY_PWD"]?.toString() ?: ""
}
}
create("release") {
if (useReleaseKeystore) {
storeFile = rootProject.file("release/app-release.jks")
storePassword = properties["TIVI_RELEASE_KEYSTORE_PWD"]?.toString() ?: ""
keyAlias = "tivi"
keyPassword = properties["TIVI_RELEASE_KEY_PWD"]?.toString() ?: ""
}
}

lint {
baseline = file("lint-baseline.xml")
// Disable lintVital. Not needed since lint is run on CI
checkReleaseBuilds = false
// Ignore any tests
ignoreTestSources = true
// Make the build fail on any lint errors
abortOnError = true
}

lint {
baseline = file("lint-baseline.xml")
// Disable lintVital. Not needed since lint is run on CI
checkReleaseBuilds = false
// Ignore any tests
ignoreTestSources = true
// Make the build fail on any lint errors
abortOnError = true
}

buildFeatures {
buildConfig = true
}

packaging {
resources.excludes += setOf(
// Exclude AndroidX version files
"META-INF/*.version",
// Exclude consumer proguard files
"META-INF/proguard/*",
// Exclude the Firebase/Fabric/other random properties files
"/*.properties",
"fabric/*.properties",
"META-INF/*.properties",
// License files
"LICENSE*",
// Exclude Kotlin unused files
"META-INF/**/previous-compilation-data.bin",
)
}

buildTypes {
debug {
signingConfig = signingConfigs["debug"]
versionNameSuffix = "-dev"
applicationIdSuffix = ".debug"
}

buildFeatures {
buildConfig = true
release {
signingConfig = signingConfigs[if (useReleaseKeystore) "release" else "debug"]
isShrinkResources = true
isMinifyEnabled = true
proguardFiles("proguard-rules.pro")
}

packaging {
resources.excludes += setOf(
// Exclude AndroidX version files
"META-INF/*.version",
// Exclude consumer proguard files
"META-INF/proguard/*",
// Exclude the Firebase/Fabric/other random properties files
"/*.properties",
"fabric/*.properties",
"META-INF/*.properties",
// License files
"LICENSE*",
// Exclude Kotlin unused files
"META-INF/**/previous-compilation-data.bin",
)
create("benchmark") {
initWith(buildTypes["release"])
signingConfig = signingConfigs["debug"]
matchingFallbacks += "release"
proguardFiles("benchmark-rules.pro")
}

buildTypes {
debug {
signingConfig = signingConfigs["debug"]
versionNameSuffix = "-dev"
applicationIdSuffix = ".debug"
}

release {
signingConfig = signingConfigs[if (useReleaseKeystore) "release" else "debug"]
isShrinkResources = true
isMinifyEnabled = true
proguardFiles("proguard-rules.pro")
}

create("benchmark") {
initWith(buildTypes["release"])
signingConfig = signingConfigs["debug"]
matchingFallbacks += "release"
proguardFiles("benchmark-rules.pro")
}
}

flavorDimensions += "mode"
productFlavors {
create("qa") {
dimension = "mode"
// This is a build with Chucker enabled
proguardFiles("proguard-rules-chucker.pro")
versionNameSuffix = "-qa"
}

flavorDimensions += "mode"
productFlavors {
create("qa") {
dimension = "mode"
// This is a build with Chucker enabled
proguardFiles("proguard-rules-chucker.pro")
versionNameSuffix = "-qa"
}

create("standard") {
dimension = "mode"
// Standard build is always ahead of the QA builds as it goes straight to
// the alpha channel. This is the 'release' flavour
versionCode = (android.defaultConfig.versionCode ?: 0) + 1
}
create("standard") {
dimension = "mode"
// Standard build is always ahead of the QA builds as it goes straight to
// the alpha channel. This is the 'release' flavour
versionCode = (android.defaultConfig.versionCode ?: 0) + 1
}

testOptions {
managedDevices {
devices {
create<com.android.build.api.dsl.ManagedVirtualDevice>("api31") {
device = "Pixel 6"
apiLevel = 31
systemImageSource = "aosp"
}
}
}

testOptions {
managedDevices {
devices {
create<com.android.build.api.dsl.ManagedVirtualDevice>("api31") {
device = "Pixel 6"
apiLevel = 31
systemImageSource = "aosp"
}
}
}
}
}

androidComponents {
// Ignore the QA Benchmark variant
val qaBenchmark = selector()
.withBuildType("benchmark")
.withFlavor("mode" to "qa")
beforeVariants(qaBenchmark) { variant ->
variant.enable = false
}

// Ignore the standardDebug variant
val standard = selector()
.withBuildType("debug")
.withFlavor("mode" to "standard")
beforeVariants(standard) { variant ->
variant.enable = false
}
// Ignore the QA Benchmark variant
val qaBenchmark = selector()
.withBuildType("benchmark")
.withFlavor("mode" to "qa")
beforeVariants(qaBenchmark) { variant ->
variant.enable = false
}

// Ignore the standardDebug variant
val standard = selector()
.withBuildType("debug")
.withFlavor("mode" to "standard")
beforeVariants(standard) { variant ->
variant.enable = false
}
}

dependencies {
qaImplementation(projects.shared.qa)
standardImplementation(projects.shared.prod)
qaImplementation(projects.shared.qa)
standardImplementation(projects.shared.prod)

implementation(libs.androidx.activity.activity)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.browser)
implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.splashscreen)
implementation(libs.androidx.activity.activity)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.browser)
implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.splashscreen)

qaImplementation(libs.leakCanary)
qaImplementation(libs.leakCanary)

implementation(libs.kotlin.coroutines.android)
implementation(libs.kotlin.coroutines.android)

implementation(libs.google.firebase.crashlytics)
implementation(libs.google.firebase.crashlytics)

androidTestImplementation(projects.androidApp.commonTest)
androidTestImplementation(libs.androidx.uiautomator)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.rules)
androidTestImplementation(projects.androidApp.commonTest)
androidTestImplementation(libs.androidx.uiautomator)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.rules)
}

if (file("google-services.json").exists()) {
apply(plugin = libs.plugins.gms.googleServices.get().pluginId)
apply(plugin = libs.plugins.firebase.crashlytics.get().pluginId)
apply(plugin = libs.plugins.gms.googleServices.get().pluginId)
apply(plugin = libs.plugins.firebase.crashlytics.get().pluginId)

// Disable uploading mapping files for the benchmark build type
android.buildTypes.getByName("benchmark") {
configure<com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension> {
mappingFileUploadEnabled = false
}
// Disable uploading mapping files for the benchmark build type
android.buildTypes.getByName("benchmark") {
configure<com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension> {
mappingFileUploadEnabled = false
}
}
}

fun DependencyHandler.qaImplementation(dependencyNotation: Any) =
add("qaImplementation", dependencyNotation)
add("qaImplementation", dependencyNotation)

fun DependencyHandler.standardImplementation(dependencyNotation: Any) =
add("standardImplementation", dependencyNotation)
add("standardImplementation", dependencyNotation)
Loading