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

[Permissions-Lint] Migrate gradle file to Kotlin DSL #1631

Merged
merged 2 commits into from
Oct 10, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" }
88 changes: 0 additions & 88 deletions permissions-lint/build.gradle

This file was deleted.

88 changes: 88 additions & 0 deletions permissions-lint/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

kotlin {
explicitApi()
}

lint {
htmlReport = true
htmlOutput = file("lint-report.html")
textReport = true
absolutePaths = false
ignoreTestSources = true
}

affectedTestConfiguration {
jvmTestTask = "test"
}

/**
* Creates a configuration for users to use that will be used bundle these dependency
* jars inside of this lint check's jar. This is required because lintPublish does
* not currently support dependencies, so instead we need to bundle any dependencies with the
* lint jar manually. (b/182319899)
*/
val bundleInside: Configuration = configurations.create("bundleInside")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to rename this for the dependency function to work

// bundleInside dependencies should be included as compileOnly and testImplementation as well
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 ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I this this should do the same as the collect function did in groovy here 🤔

if (file.isDirectory) {
file
} else {
zipTree(file)
}
}
})
}

dependencies {
// Bundle metadataJvm inside the Jar
bundleInside(libs.kotlin.metadataJvm)

oas004 marked this conversation as resolved.
Show resolved Hide resolved
compileOnly(libs.android.tools.lint.api)
compileOnly(libs.kotlin.reflect)
compileOnly(libs.kotlin.stdlib)
compileOnly(libs.kotlin.stdlibJdk8) // Override version from transitive dependencies

testImplementation(libs.junit)
testImplementation(libs.kotlin.reflect)
testImplementation(libs.kotlin.stdlib)
testImplementation(libs.kotlin.stdlibJdk8) // Override version from transitive dependencies
testImplementation(libs.android.tools.lint.lint)
testImplementation(libs.android.tools.lint.tests)
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Loading