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 | |
Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 20 | import androidx.build.BuildServerConfigurationKt |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 21 | import androidx.build.LibraryType |
David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 22 | import androidx.build.SdkResourceGenerator |
Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 23 | |
| 24 | plugins { |
| 25 | id("AndroidXPlugin") |
| 26 | id("kotlin") |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 27 | id("java-gradle-plugin") |
Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 28 | } |
| 29 | |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 30 | |
| 31 | // We need 'java-gradle-plugin' on classpath for Gradle test kit projects. If it's not, we get the following error: |
| 32 | // org.gradle.testkit.runner.InvalidPluginMetadataException: Test runtime classpath does not contain |
| 33 | // plugin metadata file 'plugin-under-test-metadata.properties'but if we generate a .jar |
| 34 | // |
| 35 | // However, if we actually run the :jar task for buildSrc-tests we get the following warning log: |
| 36 | // |
| 37 | // :buildSrc-tests:jar: No valid plugin descriptors were found in META-INF/gradle-plugins |
| 38 | // so we disable it. |
| 39 | jar.enabled = false |
| 40 | |
David Saff | d6a966c | 2022-07-26 10:54:47 -0400 | [diff] [blame] | 41 | apply from: "../buildSrc/kotlin-dsl-dependency.gradle" |
| 42 | |
| 43 | def buildSrcJar(jarName) { |
| 44 | return project.files( |
| 45 | new File( |
| 46 | BuildServerConfigurationKt.getRootOutDirectory(project), |
| 47 | "buildSrc/$jarName/build/libs/${jarName}.jar" |
| 48 | ) |
| 49 | ) |
| 50 | } |
| 51 | |
Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 52 | dependencies { |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 53 | |
| 54 | implementation(findGradleKotlinDsl()) |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 55 | implementation(gradleApi()) |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 56 | implementation(libs.androidGradlePluginz) |
David Saff | d6a966c | 2022-07-26 10:54:47 -0400 | [diff] [blame] | 57 | implementation(buildSrcJar("private")) |
| 58 | implementation(buildSrcJar("public")) |
| 59 | implementation(buildSrcJar("jetpad-integration")) |
Jeff Gaston | d0c7ebd | 2021-12-21 11:14:53 -0500 | [diff] [blame] | 60 | implementation("com.googlecode.json-simple:json-simple:1.1") |
Alan Viverette | fdbce5c | 2022-03-14 17:00:52 +0000 | [diff] [blame] | 61 | implementation(libs.gson) |
Alan Viverette | 6b52a14 | 2022-03-21 16:49:27 -0400 | [diff] [blame] | 62 | implementation(libs.dom4j) { |
| 63 | // Optional dependency where Ivy fails to parse the POM file. |
| 64 | exclude(group:"net.java.dev.msv", module:"xsdlib") |
| 65 | } |
Alan Viverette | 6ac74fb3 | 2022-06-03 13:06:32 -0400 | [diff] [blame] | 66 | // Required for dom4j to parse comments correctly. |
| 67 | implementation(libs.xerces) |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 68 | implementation(libs.kotlinGradlePluginz) |
David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 69 | |
| 70 | testImplementation(libs.junit) |
| 71 | testImplementation(libs.truth) |
| 72 | testImplementation(project(":internal-testutils-gradle-plugin")) |
Aurimas Liutikas | 6a10e89 | 2023-01-27 14:39:43 -0800 | [diff] [blame] | 73 | testImplementation(project(":internal-testutils-truth")) |
David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 74 | testImplementation(gradleTestKit()) |
David Saff | ecae583 | 2022-04-14 13:14:57 -0400 | [diff] [blame] | 75 | testImplementation(libs.checkmark) |
David Saff | d6a966c | 2022-07-26 10:54:47 -0400 | [diff] [blame] | 76 | testImplementation(libs.toml) |
Jeff Gaston | 8fd9fc8 | 2019-07-26 14:26:10 -0400 | [diff] [blame] | 77 | } |
| 78 | |
David Saff | 2eb919d | 2022-03-24 16:50:42 -0400 | [diff] [blame] | 79 | SdkResourceGenerator.generateForHostTest(project) |
| 80 | |
Aurimas Liutikas | 420b7f6 | 2022-08-02 13:53:39 -0700 | [diff] [blame] | 81 | tasks.withType(Test).configureEach { |
| 82 | // https://github.com/gradle/gradle/issues/22317 |
| 83 | it.jvmArgs = ["--add-opens=java.base/java.lang=ALL-UNNAMED"] |
| 84 | } |
| 85 | |
Fred Sladkey | ab7e4bb | 2023-02-24 16:40:43 -0500 | [diff] [blame] | 86 | androidx { |
| 87 | type = LibraryType.INTERNAL_HOST_TEST_LIBRARY |
| 88 | } |
| 89 | |
Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 90 | // Also do style checking of the buildSrc project from within this project |
Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 91 | // We run that from this project so that it doesn't block other projects while it runs |
Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 92 | def ktlintDir = file("../buildSrc") |
Jeff Gaston | 6a59789 | 2021-09-01 16:30:32 -0400 | [diff] [blame] | 93 | def subdirs = ["plugins", "private", "public"] |
Jeff Gaston | 6a59789 | 2021-09-01 16:30:32 -0400 | [diff] [blame] | 94 | |
Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 95 | tasks["ktlint"].configure({ t -> |
Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 96 | t.overrideDirectory = ktlintDir |
| 97 | t.overrideSubdirectories = subdirs |
Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 98 | }) |
| 99 | tasks["ktlintFormat"].configure({ t -> |
Aurimas Liutikas | 8cf41f5 | 2022-01-06 15:09:20 -0800 | [diff] [blame] | 100 | t.overrideDirectory = ktlintDir |
| 101 | t.overrideSubdirectories = subdirs |
Jeff Gaston | d61ec62 | 2020-02-26 15:34:00 -0500 | [diff] [blame] | 102 | }) |
Alan Viverette | 4411aa1 | 2021-05-07 18:33:11 -0400 | [diff] [blame] | 103 | |
Aurimas Liutikas | ecb21b6 | 2023-07-07 14:55:55 -0700 | [diff] [blame] | 104 | tasks["ktCheck"].configure({ t -> |
| 105 | t.overrideDirectory = ktlintDir |
| 106 | t.overrideSubdirectories = subdirs |
| 107 | }) |
| 108 | tasks["ktFormat"].configure({ t -> |
| 109 | t.overrideDirectory = ktlintDir |
| 110 | t.overrideSubdirectories = subdirs |
| 111 | }) |