From f11dcfaea14249b059aea2474ce36a0665140d4f Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 16 Feb 2022 06:36:09 -0800 Subject: [PATCH] Allow to setup a Gradle Enterprise instance via an external script Summary: This diff allows to setup a Gradle Enterprise instance either locally or on CI via an external Gradle script. I've create a `.sample` script that users can copy to start setting up their GE instance, should they have one. Moreover, it applies the `com.gradle.enterprise` Gradle plugin by default. This has the positive side effect of not invalidating build cache for the included build if you happen to pass the `--scan` flag in OSS (as the classpath isn't changed). Changelog: [Android] [Added] - Allow to setup a Gradle Enterprise instance via an external script Reviewed By: mdvacca Differential Revision: D33582388 fbshipit-source-id: 0c2f073cf7a8e39963b0adfc3b339b14c1e7759b --- gradle/gradle-enterprise.gradle.kts.sample | 17 +++++++++++++++++ settings.gradle.kts | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 gradle/gradle-enterprise.gradle.kts.sample diff --git a/gradle/gradle-enterprise.gradle.kts.sample b/gradle/gradle-enterprise.gradle.kts.sample new file mode 100644 index 00000000000..91940e25ec4 --- /dev/null +++ b/gradle/gradle-enterprise.gradle.kts.sample @@ -0,0 +1,17 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// You can use this script to configure the gradleEnterprise{} block in your build. +// You need to rename this file to ./gradle/gradle-enterprise.gradle.kts in order for +// this to be processed. +extensions.getByName("gradleEnterprise").withGroovyBuilder { + setProperty("server", "https://your-gradle-enterprise-instance.example.com") + getProperty("buildScan").withGroovyBuilder { + "publishAlways"() + "tag"(if(System.getenv("CI") != null) "CI" else "Local") + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 8e594514423..6d1179da696 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,3 +22,14 @@ include( // Include this to enable codegen Gradle plugin. includeBuild("packages/react-native-gradle-plugin/") +rootProject.name = "react-native-github" + +plugins { + id("com.gradle.enterprise").version("3.7.1") +} + +// If you specify a file inside gradle/gradle-enterprise.gradle.kts +// you can configure your custom Gradle Enterprise instance +if (File("./gradle/gradle-enterprise.gradle.kts").exists()) { + apply(from = "./gradle/gradle-enterprise.gradle.kts") +} \ No newline at end of file