Skip to content

Commit

Permalink
Migrate permissions-lint to Kotlin DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
oas004 committed Sep 28, 2023
1 parent b98cacd commit 5670636
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ coroutines = "1.6.4"
okhttp = "3.12.13"
coil = "1.3.2"

androidlint = "25.3.0"
androidxtest = "1.4.0"
androidxnavigation = "2.7.0-alpha01"
androidxWindow = "1.0.0"
Expand Down Expand Up @@ -107,6 +108,7 @@ squareup-mockwebserver = "com.squareup.okhttp3:mockwebserver:4.9.3"
android-application = { id = "com.android.application", version.ref = "gradlePlugin" }
android-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
android-library = { id = "com.android.library", version.ref = "gradlePlugin" }
android-lint = { id = "com.android.lint", version.ref = "androidlint"}
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
gradle-metalava = { id = "me.tylerbwong.gradle.metalava", version.ref = "metalava" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechPublish" }
46 changes: 23 additions & 23 deletions permissions-lint/build.gradle → permissions-lint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/

plugins {
id("java-library")
`java-library`
id("kotlin")
id("org.jetbrains.dokka")
id("com.android.lint")
id(libs.plugins.jetbrains.dokka.get().pluginId)
id(libs.plugins.android.lint.get().pluginId)
}

kotlin {
explicitApi()
}

lintOptions {
lint {
htmlReport = true
htmlOutput = file("lint-report.html")
textReport = true
Expand All @@ -43,26 +43,26 @@ affectedTestConfiguration {
* not currently support dependencies, so instead we need to bundle any dependencies with the
* lint jar manually. (b/182319899)
*/
def bundle = configurations.create("bundleInside")
val bundleInside: Configuration = configurations.create("bundleInside")
// bundleInside dependencies should be included as compileOnly and testImplementation as well
configurations.getByName("compileOnly").setExtendsFrom([bundle])
configurations.getByName("testImplementation").setExtendsFrom([bundle])
tasks.named("jar").configure { task ->
def jarTask = task as Jar
jarTask.dependsOn(bundle)
jarTask.from({
bundle
// The stdlib is already bundled with lint, so no need to include it manually
// in the lint.jar if any dependencies here depend on it
.filter { !it.name.contains("kotlin-stdlib") }
.collect { file ->
if (file.isDirectory()) {
file
} else {
zipTree(file)
}
}
})
configurations.getByName("compileOnly").setExtendsFrom(setOf(bundleInside))
configurations.getByName("testImplementation").setExtendsFrom(setOf(bundleInside))

tasks.getByName<Jar>("jar") {
this.dependsOn(bundleInside)
this.from({
bundleInside
// The stdlib is already bundled with lint, so no need to include it manually
// in the lint.jar if any dependencies here depend on it
.filter { !it.name.contains("kotlin-stdlib") }
.map { file ->
if (file.isDirectory) {
file
} else {
zipTree(file)
}
}
})
}

dependencies {
Expand Down

0 comments on commit 5670636

Please sign in to comment.