1 /* <lambda>null2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 plugins { 18 `java-library` 19 id("kotlin") 20 id(libs.plugins.jetbrains.dokka.get().pluginId) 21 id(libs.plugins.android.lint.get().pluginId) 22 } 23 <lambda>null24kotlin { 25 explicitApi() 26 } 27 <lambda>null28lint { 29 htmlReport = true 30 htmlOutput = file("lint-report.html") 31 textReport = true 32 absolutePaths = false 33 ignoreTestSources = true 34 } 35 <lambda>null36affectedTestConfiguration { 37 jvmTestTask = "test" 38 } 39 40 /** 41 * Creates a configuration for users to use that will be used bundle these dependency 42 * jars inside of this lint check's jar. This is required because lintPublish does 43 * not currently support dependencies, so instead we need to bundle any dependencies with the 44 * lint jar manually. (b/182319899) 45 */ 46 val bundleInside: Configuration = configurations.create("bundleInside") 47 // bundleInside dependencies should be included as compileOnly and testImplementation as well 48 configurations.getByName("compileOnly").setExtendsFrom(setOf(bundleInside)) 49 configurations.getByName("testImplementation").setExtendsFrom(setOf(bundleInside)) 50 <lambda>null51tasks.getByName<Jar>("jar") { 52 this.dependsOn(bundleInside) 53 this.from({ 54 bundleInside 55 // The stdlib is already bundled with lint, so no need to include it manually 56 // in the lint.jar if any dependencies here depend on it 57 .filter { !it.name.contains("kotlin-stdlib") } 58 .map { file -> 59 if (file.isDirectory) { 60 file 61 } else { 62 zipTree(file) 63 } 64 } 65 }) 66 } 67 <lambda>null68dependencies { 69 // Bundle metadataJvm inside the Jar 70 bundleInside(libs.kotlin.metadataJvm) 71 72 compileOnly(libs.android.tools.lint.api) 73 compileOnly(libs.kotlin.reflect) 74 compileOnly(libs.kotlin.stdlib) 75 compileOnly(libs.kotlin.stdlibJdk8) // Override version from transitive dependencies 76 77 testImplementation(libs.junit) 78 testImplementation(libs.kotlin.reflect) 79 testImplementation(libs.kotlin.stdlib) 80 testImplementation(libs.kotlin.stdlibJdk8) // Override version from transitive dependencies 81 testImplementation(libs.android.tools.lint.lint) 82 testImplementation(libs.android.tools.lint.tests) 83 } 84 85 java { 86 sourceCompatibility = JavaVersion.VERSION_1_8 87 targetCompatibility = JavaVersion.VERSION_1_8 88 }