|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +import org.gradle.api.internal.classpath.ModuleRegistry |
| 9 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 10 | +import org.gradle.configurationcache.extensions.serviceOf |
| 11 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 12 | + |
| 13 | +plugins { |
| 14 | + alias(libs.plugins.kotlin.jvm) |
| 15 | + id("java-gradle-plugin") |
| 16 | +} |
| 17 | + |
| 18 | +repositories { |
| 19 | + google() |
| 20 | + mavenCentral() |
| 21 | +} |
| 22 | + |
| 23 | +gradlePlugin { |
| 24 | + plugins { |
| 25 | + create("react") { |
| 26 | + id = "com.facebook.react" |
| 27 | + implementationClass = "com.facebook.react.ReactPlugin" |
| 28 | + } |
| 29 | + create("reactrootproject") { |
| 30 | + id = "com.facebook.react.rootproject" |
| 31 | + implementationClass = "com.facebook.react.ReactRootProjectPlugin" |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +group = "com.facebook.react" |
| 37 | + |
| 38 | +dependencies { |
| 39 | + implementation(gradleApi()) |
| 40 | + |
| 41 | + // The KGP/AGP version is defined by React Native Gradle plugin. |
| 42 | + // Therefore we specify an implementation dep rather than a compileOnly. |
| 43 | + implementation(libs.kotlin.gradle.plugin) |
| 44 | + implementation(libs.android.gradle.plugin) |
| 45 | + |
| 46 | + implementation(libs.gson) |
| 47 | + implementation(libs.guava) |
| 48 | + implementation(libs.javapoet) |
| 49 | + |
| 50 | + testImplementation(libs.junit) |
| 51 | + |
| 52 | + testRuntimeOnly( |
| 53 | + files( |
| 54 | + serviceOf<ModuleRegistry>() |
| 55 | + .getModule("gradle-tooling-api-builders") |
| 56 | + .classpath |
| 57 | + .asFiles |
| 58 | + .first())) |
| 59 | +} |
| 60 | + |
| 61 | +// We intentionally don't build for Java 17 as users will see a cryptic bytecode version |
| 62 | +// error first. Instead we produce a Java 11-compatible Gradle Plugin, so that AGP can print their |
| 63 | +// nice message showing that JDK 11 (or 17) is required first |
| 64 | +java { targetCompatibility = JavaVersion.VERSION_11 } |
| 65 | + |
| 66 | +kotlin { jvmToolchain(17) } |
| 67 | + |
| 68 | +tasks.withType<KotlinCompile>().configureEach { |
| 69 | + kotlinOptions { |
| 70 | + apiVersion = "1.6" |
| 71 | + // See comment above on JDK 11 support |
| 72 | + jvmTarget = "11" |
| 73 | + allWarningsAsErrors = true |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +tasks.withType<Test>().configureEach { |
| 78 | + testLogging { |
| 79 | + exceptionFormat = TestExceptionFormat.FULL |
| 80 | + showExceptions = true |
| 81 | + showCauses = true |
| 82 | + showStackTraces = true |
| 83 | + } |
| 84 | +} |
0 commit comments