Skip to content

Commit

Permalink
[ANDR][dev] Run lint on every project and apply same config everywhere (
Browse files Browse the repository at this point in the history
  • Loading branch information
murki authored Aug 28, 2024
1 parent d77bd02 commit eef3dc8
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 21 deletions.
10 changes: 10 additions & 0 deletions platform/jvm/capture-apollo3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

lint {
quiet = false
ignoreWarnings = false
warningsAsErrors = true
checkAllWarnings = true
abortOnError = true
checkDependencies = true
checkReleaseBuilds = true
}
}

detekt {
Expand Down
10 changes: 10 additions & 0 deletions platform/jvm/capture-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

lint {
quiet = false
ignoreWarnings = false
warningsAsErrors = true
checkAllWarnings = true
abortOnError = true
checkDependencies = true
checkReleaseBuilds = true
}
}

detekt {
Expand Down
14 changes: 9 additions & 5 deletions platform/jvm/capture/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
plugins {
// The rust android gradle plugin needs to go first
// see: https://github.com/mozilla/rust-android-gradle/issues/147
alias(libs.plugins.rust.android)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.rust.android)
alias(libs.plugins.detekt)

// Publish
Expand Down Expand Up @@ -37,6 +39,8 @@ dependencies {
}

android {
namespace = "io.bitdrift.capture"

compileSdk = 34
buildToolsVersion = "34.0.0"

Expand All @@ -58,6 +62,8 @@ android {
languageVersion = "1.9"
}

// TODO(murki): Move this common configuration to a reusable buildSrc plugin once it's fully supported for kotlin DSL
// see: https://github.com/gradle/kotlin-dsl-samples/issues/1287
lint {
quiet = false
ignoreWarnings = false
Expand All @@ -68,17 +74,15 @@ android {
checkReleaseBuilds = true
}

namespace = "io.bitdrift.capture"

ndkVersion = "27.0.12077973"
}

// Rust cargo build toolchain
cargo {
libname = "capture"
extraCargoBuildArguments = listOf("--package", "capture")
module = "../.."
targetDirectory = "../../../target"
module = "../.."
targetDirectory = "../../../target"
targets = listOf("arm64", "x86_64")
pythonCommand = "python3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal class ErrorHandler : ErrorHandler {
* @param detail a string identifying the action that resulted in an error.
* @param e the throwable associated with the error.
*/
@Suppress("TooGenericExceptionCaught")
override fun handleError(detail: String, e: Throwable?) {
try {
// Delegate to the JNI function over using the error reporter directly. This is done so
Expand Down
7 changes: 5 additions & 2 deletions platform/jvm/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
}

android {
namespace = "io.bitdrift.capture.common"

compileSdk = 34

compileOptions {
Expand All @@ -21,9 +23,10 @@ android {
lint {
quiet = false
ignoreWarnings = false
warningsAsErrors = true
checkAllWarnings = true
abortOnError = true
checkDependencies = true
checkReleaseBuilds = true
}

namespace = "io.bitdrift.capture.common"
}
10 changes: 5 additions & 5 deletions platform/jvm/gradle-test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
implementation("androidx.navigation:navigation-ui-ktx:2.5.3")
implementation("com.apollographql.apollo3:apollo-runtime:3.8.3")
implementation("com.apollographql.apollo3:apollo-runtime:3.8.3")
implementation ("com.jakewharton.timber:timber:5.0.1")
implementation("com.jakewharton.timber:timber:5.0.1")
implementation("com.google.android.material:material:1.8.0")
implementation(libs.androidx.material3.android)

Expand All @@ -39,7 +39,7 @@ dependencies {
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.4.0")
}

android {
android {
namespace = "io.bitdrift.gradletestapp"
compileSdk = 34

Expand All @@ -63,9 +63,9 @@ android {
}

// Run lint checks on every build
applicationVariants.all {
val lintTask = tasks["lint${name.capitalize()}"]
assembleProvider.get().dependsOn.add(lintTask)
applicationVariants.configureEach {
val lintTask = tasks.named("lint${name.replaceFirstChar(Char::titlecase)}")
assembleProvider.get().dependsOn(lintTask)
}
lint {
checkDependencies = true
Expand Down
8 changes: 4 additions & 4 deletions platform/jvm/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
androidBenchkmarkPlugin = "1.2.4"
androidGradlePlugin = "8.3.2"
androidGradlePlugin = "8.2.2" # have to pin to this version due to 8.3.x breaking our lint https://issuetracker.google.com/issues/332755363
apolloGraphqlPlugin = "3.8.3"
appcompat = "1.5.1"
assertjCore = "3.22.0"
Expand Down Expand Up @@ -57,7 +57,7 @@ android-benchmark = { id = "androidx.benchmark", version.ref = "androidBenchkmar
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
apollo-graphql = { id = "com.apollographql.apollo3", version.ref = "apolloGraphqlPlugin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detektPlugin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaPlugin"}
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublishPlugin"}
dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaPlugin" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublishPlugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinAndroidPlugin" }
rust-android = { id = "org.mozilla.rust-android-gradle.rust-android", version.ref = "rustAndroidPlugin"}
rust-android = { id = "org.mozilla.rust-android-gradle.rust-android", version.ref = "rustAndroidPlugin" }
2 changes: 1 addition & 1 deletion platform/jvm/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 5 additions & 2 deletions platform/jvm/replay/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies {
}

android {
namespace = "io.bitdrift.capture.replay"

compileSdk = 34

defaultConfig {
Expand All @@ -41,9 +43,10 @@ android {
lint {
quiet = false
ignoreWarnings = false
warningsAsErrors = true
checkAllWarnings = true
abortOnError = true
checkDependencies = true
checkReleaseBuilds = true
}

namespace = "io.bitdrift.capture.replay"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal class WindowManager(private val errorHandler: ErrorHandler) {
private var tryWindowInspector = true

private val global by lazy(LazyThreadSafetyMode.NONE) {
//noinspection PrivateApi
Class.forName("android.view.WindowManagerGlobal")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ internal class TextMapper(
return view.text.substring(lineStart, lineEnd)
}

@SuppressLint("SwitchIntDef")
@SuppressLint("SwitchIntDef", "RtlHardcoded")
private fun alignHorizontal(
view: TextView,
alignment: Int = view.textAlignment,
Expand Down

0 comments on commit eef3dc8

Please sign in to comment.