blob: d70a6889c8dd54a8b196d619d2544c7f0dbd931d [file] [log] [blame]
Jeff Gaston8fd9fc82019-07-26 14:26:10 -04001/*
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 Sladkeyab7e4bb2023-02-24 16:40:43 -050020import androidx.build.LibraryType
Aurimas Liutikasfab019a2024-02-06 22:16:54 -080021import androidx.build.KotlinTarget
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040022
23plugins {
24 id("AndroidXPlugin")
25 id("kotlin")
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050026 id("java-gradle-plugin")
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040027}
28
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050029
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 Sladkeyab7e4bb2023-02-24 16:40:43 -050038
David Saffd6a966c2022-07-26 10:54:47 -040039apply from: "../buildSrc/kotlin-dsl-dependency.gradle"
40
Aurimas Liutikasfab019a2024-02-06 22:16:54 -080041sourceSets {
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 Saffd6a966c2022-07-26 10:54:47 -040051}
52
Aurimas Liutikasfab019a2024-02-06 22:16:54 -080053apply from: "${buildscript.sourceFile.parentFile.parent}/buildSrc/shared-dependencies.gradle"
David Saff2eb919d2022-03-24 16:50:42 -040054
Aurimas Liutikasfab019a2024-02-06 22:16:54 -080055dependencies {
Radha Nakade0c51a2e2024-06-26 11:29:54 -070056 api(libs.javaxInject)
Aurimas Liutikas2e6b1a22024-09-11 10:01:11 -070057 api(libs.shadow)
Radha Nakade0c51a2e2024-06-26 11:29:54 -070058 api(libs.guavaAndroid)
59 api(libs.kotlinGradlePluginApi)
60 api(libs.kotlinNativeUtils)
61 api(libs.kotlinStdlib)
62
Aurimas Liutikasfab019a2024-02-06 22:16:54 -080063 implementation(project(":benchmark:benchmark-gradle-plugin"))
64 implementation(project(":inspection:inspection-gradle-plugin"))
65 implementation(project(":stableaidl:stableaidl-gradle-plugin"))
Fred Sladkeycdb946c2024-05-01 13:02:21 -040066 implementation(project(":binarycompatibilityvalidator:binarycompatibilityvalidator"))
Jeff Gastonf2f81c52024-04-18 11:51:29 -040067 implementation(project.ext.findGradleKotlinDsl())
Aurimas Liutikasc7ebc6c2024-06-14 15:11:59 -070068 // 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 Nakade0c51a2e2024-06-26 11:29:54 -070071 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 Saff2eb919d2022-03-24 16:50:42 -040079 testImplementation(libs.junit)
80 testImplementation(libs.truth)
81 testImplementation(project(":internal-testutils-gradle-plugin"))
Aurimas Liutikas6a10e8932023-01-27 14:39:43 -080082 testImplementation(project(":internal-testutils-truth"))
David Saff2eb919d2022-03-24 16:50:42 -040083 testImplementation(gradleTestKit())
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040084}
85
Aurimas Liutikas420b7f62022-08-02 13:53:39 -070086tasks.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 Sladkeyab7e4bb2023-02-24 16:40:43 -050091androidx {
Omar Ismaila293b972024-12-16 12:18:54 +000092 type = LibraryType.INTERNAL_GRADLE_PLUGIN
Aurimas Liutikasfab019a2024-02-06 22:16:54 -080093 kotlinTarget = KotlinTarget.KOTLIN_1_9
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050094}
95
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -080096// Also do style checking of the buildSrc project from within this project
Jeff Gastond61ec622020-02-26 15:34:00 -050097// We run that from this project so that it doesn't block other projects while it runs
Omar Ismailff4fb232024-06-03 16:39:30 +010098def ktfmtDir = file("../buildSrc")
Jeff Gaston6a597892021-09-01 16:30:32 -040099def subdirs = ["plugins", "private", "public"]
Jeff Gaston6a597892021-09-01 16:30:32 -0400100
Omar Ismail1a1b3c92024-05-22 10:14:38 +0100101tasks["ktCheck"].configure({ t ->
Omar Ismailff4fb232024-06-03 16:39:30 +0100102 t.overrideDirectory = ktfmtDir
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -0800103 t.overrideSubdirectories = subdirs
Jeff Gastond61ec622020-02-26 15:34:00 -0500104})
Omar Ismail1a1b3c92024-05-22 10:14:38 +0100105tasks["ktFormat"].configure({ t ->
Omar Ismailff4fb232024-06-03 16:39:30 +0100106 t.overrideDirectory = ktfmtDir
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -0800107 t.overrideSubdirectories = subdirs
Jeff Gastond61ec622020-02-26 15:34:00 -0500108})
Alan Viverette4411aa12021-05-07 18:33:11 -0400109