Skip to content

Commit

Permalink
Add property to override lint version (#767)
Browse files Browse the repository at this point in the history
This allows us to specify it programmatically and source our version
catalogs rather than only statically in `gradle.properties`

<!--
  ⬆ Put your description above this! ⬆

  Please be descriptive and detailed.
  
Please read our [Contributing
Guidelines](https://github.com/tinyspeck/slack-gradle-plugin/blob/main/.github/CONTRIBUTING.md)
and [Code of Conduct](https://slackhq.github.io/code-of-conduct).

Don't worry about deleting this, it's not visible in the PR!
-->
  • Loading branch information
ZacSweers authored Mar 6, 2024
1 parent 7db05c6 commit 8b0a9df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions slack-plugin/src/main/kotlin/slack/gradle/SlackProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ internal constructor(
public val lintIgnoreTestSources: Boolean
get() = booleanProperty("sgp.lint.ignoreTestSources", false)

/**
* Flag to control which agp version should be used for lint. Optional. Value should be a version
* key in `libs.versions.toml`,
*/
public val lintVersionOverride: String?
get() = optionalStringProperty("sgp.lint.agpVersion")

/**
* Flag to indicate whether this project is a test library (such as test utils, test fixtures,
* etc).
Expand Down
2 changes: 2 additions & 0 deletions slack-plugin/src/main/kotlin/slack/gradle/SlackVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ internal class SlackVersions(val catalog: VersionCatalog) {
val robolectric: String?
get() = getOptionalValue("robolectric").orElse(null)

fun lookupVersion(key: String) = getOptionalValue(key)

val bundles = Bundles()

inner class Bundles {
Expand Down
5 changes: 5 additions & 0 deletions slack-plugin/src/main/kotlin/slack/gradle/lint/LintTasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ internal object LintTasks {
onProjectSkipped: (String, String) -> Unit,
) =
androidExtension.finalizeDsl { extension ->
slackProperties.lintVersionOverride?.let {
val lintVersion = slackProperties.versions.lookupVersion(it)
extension.experimentalProperties["android.experimental.lint.version"] = lintVersion
}

log("Applying ciLint to Android project")

log(
Expand Down

0 comments on commit 8b0a9df

Please sign in to comment.