Last active
April 28, 2020 18:05
-
-
Save rocketraman/5f0d491a8a062745b7dfe6cc4b6c475e to your computer and use it in GitHub Desktop.
Enable build scans for all builds via `~/.gradle/init.d/scans-init.gradle.kts`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin | |
import com.gradle.scan.plugin.BuildScanPlugin | |
import org.gradle.util.GradleVersion | |
initscript { | |
val pluginVersion = "3.2.1" | |
repositories { | |
gradlePluginPortal() | |
} | |
dependencies { | |
classpath("com.gradle:gradle-enterprise-gradle-plugin:${pluginVersion}") | |
} | |
} | |
val isTopLevelBuild = gradle.getParent() == null | |
if (isTopLevelBuild) { | |
val gradleVersion = GradleVersion.current().baseVersion | |
val atLeastGradle5 = gradleVersion >= GradleVersion.version("5.0") | |
val atLeastGradle6 = gradleVersion >= GradleVersion.version("6.0") | |
if (atLeastGradle6) { | |
settingsEvaluated { | |
if (!pluginManager.hasPlugin("com.gradle.enterprise")) { | |
pluginManager.apply(GradleEnterprisePlugin::class) | |
} | |
extensions["gradleEnterprise"].withGroovyBuilder { | |
configureExtension(getProperty("buildScan")) | |
} | |
} | |
} else if (atLeastGradle5) { | |
rootProject { | |
pluginManager.apply(BuildScanPlugin::class) | |
configureExtension(extensions["buildScan"]) | |
} | |
} | |
} | |
fun configureExtension(extension: Any) { | |
extension.withGroovyBuilder { | |
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service") | |
setProperty("termsOfServiceAgree", "yes") | |
// other configuration | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment