blob: 81ab23a25cd3d71d075a4ea305047917976677e0 [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
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040020import androidx.build.BuildServerConfigurationKt
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050021import androidx.build.LibraryType
David Saff2eb919d2022-03-24 16:50:42 -040022import androidx.build.SdkResourceGenerator
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040023
24plugins {
25 id("AndroidXPlugin")
26 id("kotlin")
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050027 id("java-gradle-plugin")
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040028}
29
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050030
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.
39jar.enabled = false
40
David Saffd6a966c2022-07-26 10:54:47 -040041apply from: "../buildSrc/kotlin-dsl-dependency.gradle"
42
43def 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 Gaston8fd9fc82019-07-26 14:26:10 -040052dependencies {
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050053
54 implementation(findGradleKotlinDsl())
Jim Sproch9e38b4f2021-01-06 14:21:06 -080055 implementation(gradleApi())
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050056 implementation(libs.androidGradlePluginz)
David Saffd6a966c2022-07-26 10:54:47 -040057 implementation(buildSrcJar("private"))
58 implementation(buildSrcJar("public"))
59 implementation(buildSrcJar("jetpad-integration"))
Jeff Gastond0c7ebd2021-12-21 11:14:53 -050060 implementation("com.googlecode.json-simple:json-simple:1.1")
Alan Viverettefdbce5c2022-03-14 17:00:52 +000061 implementation(libs.gson)
Alan Viverette6b52a142022-03-21 16:49:27 -040062 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 Viverette6ac74fb32022-06-03 13:06:32 -040066 // Required for dom4j to parse comments correctly.
67 implementation(libs.xerces)
Fred Sladkeyab7e4bb2023-02-24 16:40:43 -050068 implementation(libs.kotlinGradlePluginz)
David Saff2eb919d2022-03-24 16:50:42 -040069
70 testImplementation(libs.junit)
71 testImplementation(libs.truth)
72 testImplementation(project(":internal-testutils-gradle-plugin"))
Aurimas Liutikas6a10e892023-01-27 14:39:43 -080073 testImplementation(project(":internal-testutils-truth"))
David Saff2eb919d2022-03-24 16:50:42 -040074 testImplementation(gradleTestKit())
David Saffecae5832022-04-14 13:14:57 -040075 testImplementation(libs.checkmark)
David Saffd6a966c2022-07-26 10:54:47 -040076 testImplementation(libs.toml)
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040077}
78
David Saff2eb919d2022-03-24 16:50:42 -040079SdkResourceGenerator.generateForHostTest(project)
80
Aurimas Liutikas420b7f62022-08-02 13:53:39 -070081tasks.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 Sladkeyab7e4bb2023-02-24 16:40:43 -050086androidx {
87 type = LibraryType.INTERNAL_HOST_TEST_LIBRARY
88}
89
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -080090// Also do style checking of the buildSrc project from within this project
Jeff Gastond61ec622020-02-26 15:34:00 -050091// We run that from this project so that it doesn't block other projects while it runs
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -080092def ktlintDir = file("../buildSrc")
Jeff Gaston6a597892021-09-01 16:30:32 -040093def subdirs = ["plugins", "private", "public"]
Jeff Gaston6a597892021-09-01 16:30:32 -040094
Jeff Gastond61ec622020-02-26 15:34:00 -050095tasks["ktlint"].configure({ t ->
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -080096 t.overrideDirectory = ktlintDir
97 t.overrideSubdirectories = subdirs
Jeff Gastond61ec622020-02-26 15:34:00 -050098})
99tasks["ktlintFormat"].configure({ t ->
Aurimas Liutikas8cf41f52022-01-06 15:09:20 -0800100 t.overrideDirectory = ktlintDir
101 t.overrideSubdirectories = subdirs
Jeff Gastond61ec622020-02-26 15:34:00 -0500102})
Alan Viverette4411aa12021-05-07 18:33:11 -0400103
104// Broken in AGP 7.0-alpha15 due to b/180408027
105tasks["lint"].configure { t ->
106 t.enabled = false
Jeff Gastond72edf22021-08-24 11:53:54 -0400107}