Skip to content

Commit

Permalink
feat(build): add androidx.lint checks to build-logic
Browse files Browse the repository at this point in the history
  • Loading branch information
msfjarvis committed Mar 5, 2024
1 parent 9298fa9 commit 9a6d7d2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 17 deletions.
9 changes: 8 additions & 1 deletion build-logic/build.gradle.kts
Expand Up @@ -4,7 +4,10 @@
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
plugins { `kotlin-dsl` }
plugins {
`kotlin-dsl`
alias(libs.plugins.android.lint)
}

kotlin.jvmToolchain(17)

Expand Down Expand Up @@ -61,6 +64,8 @@ gradlePlugin {
}
}

lint.baseline = project.file("lint-baseline.xml")

dependencies {
implementation(libs.build.agp)
implementation(libs.build.cachefix)
Expand All @@ -72,4 +77,6 @@ dependencies {

// Expose the generated version catalog API to the plugin.
implementation(files(libs::class.java.superclass.protectionDomain.codeSource.location))

lintChecks(libs.androidx.lint)
}
26 changes: 26 additions & 0 deletions build-logic/lint-baseline.xml
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.3.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.0)" variant="all" version="8.3.0">

<issue
id="InternalGradleApiUsage"
message="Avoid using internal Android Gradle Plugin APIs"
errorLine1="import com.android.build.gradle.internal.dsl.BaseAppModuleExtension"
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/dev/msfjarvis/claw/gradle/signing/AppSigning.kt"
line="9"
column="1"/>
</issue>

<issue
id="InternalGradleApiUsage"
message="Avoid using internal Android Gradle Plugin APIs"
errorLine1="import com.android.build.gradle.internal.plugins.AppPlugin"
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/dev/msfjarvis/claw/gradle/versioning/VersioningPlugin.kt"
line="11"
column="1"/>
</issue>

</issues>
9 changes: 9 additions & 0 deletions build-logic/settings.gradle.kts
Expand Up @@ -23,6 +23,14 @@ pluginManagement {
includeModule("org.gradle.kotlin", "gradle-kotlin-dsl-plugins")
}
}
exclusiveContent {
forRepository { google() }
filter {
includeGroup("androidx.databinding")
includeGroupByRegex("com.android.*")
includeGroup("com.google.testing.platform")
}
}
mavenCentral { mavenContent { releasesOnly() } }
}
}
Expand All @@ -33,6 +41,7 @@ dependencyResolutionManagement {
forRepository(::google)
filter {
includeGroup("androidx.databinding")
includeGroup("androidx.lint")
includeGroupByRegex("com.android.*")
includeGroup("com.google.testing.platform")
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright © 2022-2023 Harsh Shandilya.
* Copyright © 2022-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
Expand Down Expand Up @@ -33,26 +33,22 @@ class ApplicationPlugin : Plugin<Project> {
buildConfig = true
}

buildTypes {
all {
setProguardFiles(
listOf(
"proguard-android-optimize.pro",
"proguard-rules.pro",
"proguard-rules-missing-classes.pro",
)
buildTypes.configureEach {
setProguardFiles(
listOf(
"proguard-android-optimize.pro",
"proguard-rules.pro",
"proguard-rules-missing-classes.pro",
)
}
named("release") {
)
if (name == "release") {
isMinifyEnabled = !project.providers.environmentVariable("DISABLE_MINIFY").isPresent
}
named("debug") {
} else if (name == "debug") {
applicationIdSuffix = ".debug"
versionNameSuffix = "-debug"
isMinifyEnabled = false
}
}

project.configureBuildSigning()
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Copyright © 2022-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
Expand Down Expand Up @@ -31,7 +31,7 @@ internal fun Project.configureBuildSigning() {
}
}
val signingConfig = signingConfigs.getByName("release")
buildTypes.all { setSigningConfig(signingConfig) }
buildTypes.configureEach { setSigningConfig(signingConfig) }
}
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Expand Up @@ -44,6 +44,7 @@ androidx-core-splashscreen = "androidx.core:core-splashscreen:1.1.0-alpha02"
androidx-lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "lifecycle" }
androidx-lifecycle-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle" }
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime", version.ref = "lifecycle" }
androidx-lint = "androidx.lint:lint-gradle:1.0.0-alpha01"
androidx-navigation-compose = "androidx.navigation:navigation-compose:2.8.0-alpha03"
androidx-paging-compose = "androidx.paging:paging-compose:3.3.0-alpha03"
androidx-profileinstaller = "androidx.profileinstaller:profileinstaller:1.4.0-alpha01"
Expand Down Expand Up @@ -108,6 +109,7 @@ unfurl = "me.saket.unfurl:unfurl:1.7.0"

[plugins]
aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutLibraries" }
android-lint = { id = "com.android.lint", version.ref = "agp" }
android-test = { id = "com.android.test", version.ref = "agp" }
anvil = "com.squareup.anvil:2.5.0-beta03"
baselineprofile = { id = "androidx.baselineprofile", version.ref = "benchmark" }
Expand Down

0 comments on commit 9a6d7d2

Please sign in to comment.