| Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 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 | |
| Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 20 | import androidx.build.LibraryType |
| Aurimas Liutikas | fab019a | 2024-02-06 22:16:54 -0800 | [diff] [blame] | 21 | import androidx.build.KotlinTarget |
| Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 22 | |
| 23 | plugins { |
| 24 | id("AndroidXPlugin") |
| 25 | id("kotlin") |
| Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 26 | id("java-gradle-plugin") |
| Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 27 | } |
| 28 | |
| Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 29 | |
| 30 | // We need 'java-gradle-plugin' on classpath for Gradle test kit projects. If it's not, we get the following error: |
| 31 | // org.gradle.testkit.runner.InvalidPluginMetadataException: Test runtime classpath does not contain |
| 32 | // plugin metadata file 'plugin-under-test-metadata.properties'but if we generate a .jar |
| 33 | // |
| 34 | // However, if we actually run the :jar task for buildSrc-tests we get the following warning log: |
| 35 | // |
| 36 | // :buildSrc-tests:jar: No valid plugin descriptors were found in META-INF/gradle-plugins |
| 37 | // so we disable it. |
| Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 38 | |
| David Saff | d6a966c | 2022-07-26 10:54:47 -0400 | [diff] [blame] | 39 | apply from: "../buildSrc/kotlin-dsl-dependency.gradle" |
| 40 | |
| Aurimas Liutikas | fab019a | 2024-02-06 22:16:54 -0800 | [diff] [blame] | 41 | sourceSets { |
| 42 | main.kotlin.srcDirs += [ |
| 43 | '../buildSrc/public/src/main/kotlin', |
| 44 | '../buildSrc/private/src/main/kotlin', |
| 45 | '../buildSrc/jetpad-integration/src/main/java' |
| 46 | ] |
| 47 | main.java.srcDirs += [ |
| 48 | '../buildSrc/jetpad-integration/src/main/java', |
| 49 | ] |
| 50 | main.resources.srcDirs += ['../buildSrc/private/src/main/resources'] |
| David Saff | d6a966c | 2022-07-26 10:54:47 -0400 | [diff] [blame] | 51 | } |
| 52 | |
| Aurimas Liutikas | fab019a | 2024-02-06 22:16:54 -0800 | [diff] [blame] | 53 | apply from: "${buildscript.sourceFile.parentFile.parent}/buildSrc/shared-dependencies.gradle" |
| David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 54 | |
| Aurimas Liutikas | fab019a | 2024-02-06 22:16:54 -0800 | [diff] [blame] | 55 | dependencies { |
| Radha Nakade | 0c51a2e | 2024-06-26 11:29:54 -0700 | [diff] [blame] | 56 | api(libs.javaxInject) |
| Aurimas Liutikas | 2e6b1a2 | 2024-09-11 10:01:11 -0700 | [diff] [blame] | 57 | api(libs.shadow) |
| Radha Nakade | 0c51a2e | 2024-06-26 11:29:54 -0700 | [diff] [blame] | 58 | api(libs.guavaAndroid) |
| 59 | api(libs.kotlinGradlePluginApi) |
| 60 | api(libs.kotlinNativeUtils) |
| 61 | api(libs.kotlinStdlib) |
| 62 | |
| Aurimas Liutikas | fab019a | 2024-02-06 22:16:54 -0800 | [diff] [blame] | 63 | implementation(project(":benchmark:benchmark-gradle-plugin")) |
| 64 | implementation(project(":inspection:inspection-gradle-plugin")) |
| 65 | implementation(project(":stableaidl:stableaidl-gradle-plugin")) |
| Fred Sladkey | cdb946c | 2024-05-01 13:02:21 -0400 | [diff] [blame] | 66 | implementation(project(":binarycompatibilityvalidator:binarycompatibilityvalidator")) |
| Jeff Gaston | f2f81c5 | 2024-04-18 11:51:29 -0400 | [diff] [blame] | 67 | implementation(project.ext.findGradleKotlinDsl()) |
| Aurimas Liutikas | c7ebc6c | 2024-06-14 15:11:59 -0700 | [diff] [blame] | 68 | // Workaround for targeting KotlinTarget.KOTLIN_1_9, but linking agaist kotlin compiler |
| 69 | // embeddable 2.0 in buildSrc |
| 70 | implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}") |
| Radha Nakade | 0c51a2e | 2024-06-26 11:29:54 -0700 | [diff] [blame] | 71 | implementation(libs.kotlinGradlePluginAnnotations) |
| 72 | implementation(libs.kotlinToolingCore) |
| 73 | implementation(libs.binaryCompatibilityValidator) |
| 74 | implementation(libs.jetbrainsBinaryCompatibilityValidator) |
| 75 | implementation(libs.xmlApis) |
| 76 | |
| 77 | testImplementation(libs.checkmark) |
| 78 | testImplementation libs.hamcrestCore |
| David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 79 | testImplementation(libs.junit) |
| 80 | testImplementation(libs.truth) |
| 81 | testImplementation(project(":internal-testutils-gradle-plugin")) |
| Aurimas Liutikas | 6a10e893 | 2023-01-27 14:39:43 -0800 | [diff] [blame] | 82 | testImplementation(project(":internal-testutils-truth")) |
| David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 83 | testImplementation(gradleTestKit()) |
| Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 84 | } |
| 85 | |
| Aurimas Liutikas | 420b7f6 | 2022-08-02 13:53:39 -0700 | [diff] [blame] | 86 | tasks.withType(Test).configureEach { |
| 87 | // https://github.com/gradle/gradle/issues/22317 |
| 88 | it.jvmArgs = ["--add-opens=java.base/java.lang=ALL-UNNAMED"] |
| 89 | } |
| 90 | |
| Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 91 | androidx { |
| Omar Ismail | a293b97 | 2024-12-16 12:18:54 +0000 | [diff] [blame] | 92 | type = LibraryType.INTERNAL_GRADLE_PLUGIN |
| Aurimas Liutikas | fab019a | 2024-02-06 22:16:54 -0800 | [diff] [blame] | 93 | kotlinTarget = KotlinTarget.KOTLIN_1_9 |
| Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 94 | } |
| 95 | |
| Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 96 | // Also do style checking of the buildSrc project from within this project |
| Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 97 | // We run that from this project so that it doesn't block other projects while it runs |
| Omar Ismail | ff4fb23 | 2024-06-03 16:39:30 +0100 | [diff] [blame] | 98 | def ktfmtDir = file("../buildSrc") |
| Jeff Gaston | 6a59789 | 2021-09-01 16:30:32 -0400 | [diff] [blame] | 99 | def subdirs = ["plugins", "private", "public"] |
| Jeff Gaston | 6a59789 | 2021-09-01 16:30:32 -0400 | [diff] [blame] | 100 | |
| Omar Ismail | 1a1b3c9 | 2024-05-22 10:14:38 +0100 | [diff] [blame] | 101 | tasks["ktCheck"].configure({ t -> |
| Omar Ismail | ff4fb23 | 2024-06-03 16:39:30 +0100 | [diff] [blame] | 102 | t.overrideDirectory = ktfmtDir |
| Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 103 | t.overrideSubdirectories = subdirs |
| Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 104 | }) |
| Omar Ismail | 1a1b3c9 | 2024-05-22 10:14:38 +0100 | [diff] [blame] | 105 | tasks["ktFormat"].configure({ t -> |
| Omar Ismail | ff4fb23 | 2024-06-03 16:39:30 +0100 | [diff] [blame] | 106 | t.overrideDirectory = ktfmtDir |
| Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 107 | t.overrideSubdirectories = subdirs |
| Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 108 | }) |
| Alan Viverette | 4411aa1 | 2021-05-07 18:33:11 -0400 | [diff] [blame] | 109 | |