1/* 2 * Copyright 2019 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 * http://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// This project contains tests for code contained in buildSrc 18// This project is stored outside of buildSrc/ so that waiting for these tests to complete doesn't delay the rest of the build 19 20import androidx.build.SoftwareType 21 22plugins { 23 id("AndroidXPlugin") 24 id("kotlin") 25 id("java-gradle-plugin") 26} 27 28 29// We need 'java-gradle-plugin' on classpath for Gradle test kit projects. If it's not, we get the following error: 30// org.gradle.testkit.runner.InvalidPluginMetadataException: Test runtime classpath does not contain 31// plugin metadata file 'plugin-under-test-metadata.properties'but if we generate a .jar 32// 33// However, if we actually run the :jar task for buildSrc-tests we get the following warning log: 34// 35// :buildSrc-tests:jar: No valid plugin descriptors were found in META-INF/gradle-plugins 36// so we disable it. 37 38apply from: "../buildSrc/kotlin-dsl-dependency.gradle" 39 40sourceSets { 41 main.kotlin.srcDirs += [ 42 '../buildSrc/public/src/main/kotlin', 43 '../buildSrc/private/src/main/kotlin', 44 '../buildSrc/jetpad-integration/src/main/java' 45 ] 46 main.java.srcDirs += [ 47 '../buildSrc/jetpad-integration/src/main/java', 48 ] 49 main.resources.srcDirs += ['../buildSrc/private/src/main/resources'] 50} 51 52apply from: "${buildscript.sourceFile.parentFile.parent}/buildSrc/shared-dependencies.gradle" 53 54dependencies { 55 api(libs.javaxInject) 56 api(libs.shadow) 57 api(libs.guavaAndroid) 58 api(libs.kotlinGradlePluginApi) 59 api(libs.kotlinNativeUtils) 60 api(libs.kotlinStdlib) 61 62 // Remove once b/407096518 is fixed 63 implementation(libs.androidGradlePlugin) 64 65 implementation(project(":benchmark:benchmark-gradle-plugin")) 66 implementation(project(":inspection:inspection-gradle-plugin")) 67 implementation(project(":stableaidl:stableaidl-gradle-plugin")) 68 implementation(project(":binarycompatibilityvalidator:binarycompatibilityvalidator")) 69 implementation(project.ext.findGradleKotlinDsl()) 70 // Workaround for targeting KotlinTarget.KOTLIN_1_9, but linking agaist kotlin compiler 71 // embeddable 2.0 in buildSrc 72 implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}") 73 implementation(libs.kotlinGradlePluginAnnotations) 74 implementation(libs.kotlinToolingCore) 75 implementation(libs.binaryCompatibilityValidator) 76 implementation(libs.jetbrainsBinaryCompatibilityValidator) 77 implementation(libs.xmlApis) 78 79 testImplementation(libs.checkmark) 80 testImplementation libs.hamcrestCore 81 testImplementation(libs.junit) 82 testImplementation(libs.truth) 83 testImplementation(project(":internal-testutils-gradle-plugin")) 84 testImplementation(project(":internal-testutils-truth")) 85 testImplementation(gradleTestKit()) 86} 87 88tasks.withType(Test).configureEach { 89 // https://github.com/gradle/gradle/issues/22317 90 it.jvmArgs = ["--add-opens=java.base/java.lang=ALL-UNNAMED"] 91} 92 93androidx { 94 type = SoftwareType.INTERNAL_GRADLE_PLUGIN 95} 96 97// Also do style checking of the buildSrc project from within this project 98// We run that from this project so that it doesn't block other projects while it runs 99def ktfmtDir = file("../buildSrc") 100def subdirs = ["plugins", "private", "public"] 101 102tasks["ktCheck"].configure({ t -> 103 t.overrideDirectory = ktfmtDir 104 t.overrideSubdirectories = subdirs 105}) 106tasks["ktFormat"].configure({ t -> 107 t.overrideDirectory = ktfmtDir 108 t.overrideSubdirectories = subdirs 109}) 110 111