Skip to content

Commit

Permalink
Support configuring the Gradle Enterprise plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Virtlink committed Jul 13, 2024
1 parent 5fa4935 commit 716f79e
Showing 1 changed file with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.metaborg.convention

import com.gradle.develocity.agent.gradle.DevelocityConfiguration
import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension
import org.gradle.api.Plugin
import org.gradle.api.initialization.Settings
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.maven


/**
* Configures a Gradle build.
*/
Expand Down Expand Up @@ -43,17 +45,32 @@ class SettingsConventionPlugin: Plugin<Settings> {
// Apply the Foojay plugin
plugins.apply("org.gradle.toolchains.foojay-resolver-convention")

// Apply and configure the Develocity plugin
plugins.apply("com.gradle.develocity")
extensions.configure(DevelocityConfiguration::class.java) {
val isCI = System.getenv("CI").isNullOrEmpty()
buildScan {
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")
publishing.onlyIf { isCI }
if (isCI) tag("CI")
capture {
fileFingerprints.set(true)
val isCI = System.getenv("CI").isNullOrEmpty()
gradle.settingsEvaluated {
if (plugins.hasPlugin("com.gradle.build-scan") || plugins.hasPlugin("com.gradle.enterprise")) {
// Configure the Gradle Enterprise plugin if it's configured
@Suppress("DEPRECATION")
settings.extensions.getByType(GradleEnterpriseExtension::class.java).apply {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
publishAlwaysIf(isCI)
if (isCI) tag("CI")
}
}
} else {
// Otherwise, apply and configure the Gradle Develocity plugin and configure it
plugins.apply("com.gradle.develocity")
settings.extensions.getByType(DevelocityConfiguration::class.java).apply {
buildScan {
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")
publishing.onlyIf { isCI }
if (isCI) tag("CI")
capture {
fileFingerprints.set(true)
}
}
}
}
}
Expand Down

0 comments on commit 716f79e

Please sign in to comment.