You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by sn...@apache.org on 2026/06/11 05:37:25 UTC

(polaris) branch main updated: Build: type provider for Develocity configuration (#4689)

This is an automated email from the ASF dual-hosted git repository.

snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 0414ef03bf Build: type provider for Develocity configuration (#4689)
0414ef03bf is described below

commit 0414ef03bfaf89e23af87636835d27f0f26bbe4f
Author: Robert Stupp <sn...@snazy.de>
AuthorDate: Thu Jun 11 07:37:21 2026 +0200

    Build: type provider for Develocity configuration (#4689)
    
    A change that's necessary to eventually be able to enable Gradle's configuration cache.
    
    No functional change.
---
 settings.gradle.kts | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/settings.gradle.kts b/settings.gradle.kts
index 6f1eb80fa2..f0871f78a0 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -17,7 +17,9 @@
  * under the License.
  */
 
+import com.gradle.develocity.agent.gradle.scan.BuildScanPublishingConfiguration
 import java.util.Properties
+import org.gradle.api.specs.Spec
 
 includeBuild("build-logic") { name = "polaris-build-logic" }
 
@@ -148,6 +150,7 @@ gradle.beforeProject {
 }
 
 val isCI = System.getenv("CI") != null
+val isBuildScanRequested = gradle.startParameter.isBuildScan
 
 develocity {
   val isApachePolarisGitHub = "apache/polaris" == System.getenv("GITHUB_REPOSITORY")
@@ -162,13 +165,13 @@ develocity {
     projectId = "polaris"
     buildScan {
       uploadInBackground = !isCI
-      publishing.onlyIf { it.isAuthenticated }
+      publishing.onlyIf(AuthenticatedBuildScanPublishingSpec())
       obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
     }
   } else {
     // In all other cases, especially PR CI runs, use Gradle's public Develocity instance.
     var cfgPrjId: String? = System.getenv("DEVELOCITY_PROJECT_ID")
-    projectId = if (cfgPrjId == null || cfgPrjId.isEmpty()) "polaris" else cfgPrjId
+    projectId = if (cfgPrjId.isNullOrEmpty()) "polaris" else cfgPrjId
     buildScan {
       val isGradleTosAccepted = "true" == System.getenv("GRADLE_TOS_ACCEPTED")
       val isGitHubPullRequest = gitHubRef?.startsWith("refs/pull/") ?: false
@@ -186,13 +189,25 @@ develocity {
         System.getenv("GITHUB_SERVER_URL")?.run {
           val ghUrl = this
           val ghRepo = System.getenv("GITHUB_REPOSITORY")
-          val prNumber = gitHubRef!!.substringAfter("refs/pull/").substringBefore("/merge")
+          val prNumber = gitHubRef.substringAfter("refs/pull/").substringBefore("/merge")
           link("GitHub pull request", "$ghUrl/$ghRepo/pull/$prNumber")
         }
       }
       uploadInBackground = !isCI
-      publishing.onlyIf { isCI || gradle.startParameter.isBuildScan }
+      publishing.onlyIf(RequestedBuildScanPublishingSpec(isCI || isBuildScanRequested))
       obfuscation { ipAddresses { addresses -> addresses.map { _ -> "0.0.0.0" } } }
     }
   }
 }
+
+class AuthenticatedBuildScanPublishingSpec :
+  Spec<BuildScanPublishingConfiguration.PublishingContext> {
+  override fun isSatisfiedBy(context: BuildScanPublishingConfiguration.PublishingContext): Boolean =
+    context.isAuthenticated
+}
+
+class RequestedBuildScanPublishingSpec(private val enabled: Boolean) :
+  Spec<BuildScanPublishingConfiguration.PublishingContext> {
+  override fun isSatisfiedBy(context: BuildScanPublishingConfiguration.PublishingContext): Boolean =
+    enabled
+}