@@ -52,6 +52,11 @@ pluginManagement {
5252 }
5353}
5454
55+ plugins {
56+ id(" com.gradle.develocity" ) version " 4.2.2"
57+ id(" com.gradle.common-custom-user-data-gradle-plugin" ) version " 2.4.0"
58+ }
59+
5560dependencyResolutionManagement {
5661 repositoriesMode = RepositoriesMode .FAIL_ON_PROJECT_REPOS
5762 repositories {
@@ -64,3 +69,58 @@ gradle.beforeProject {
6469 version = baseVersion
6570 group = " org.apache.polaris.tools.apprunner"
6671}
72+
73+ val isCI = System .getenv(" CI" ) != null
74+
75+ develocity {
76+ val isApachePolarisGitHub = " apache/polaris-tools" == System .getenv(" GITHUB_REPOSITORY" )
77+ val gitHubRef: String? = System .getenv(" GITHUB_REF" )
78+ val isGitHubBranchOrTag =
79+ gitHubRef != null && (gitHubRef.startsWith(" refs/heads/" ) || gitHubRef.startsWith(" refs/tags/" ))
80+ if (isApachePolarisGitHub && isGitHubBranchOrTag) {
81+ // Use the ASF's Develocity instance when running against the Apache Polaris repository against
82+ // a branch or tag.
83+ // This is for CI runs that have access to the secret for the ASF's Develocity instance.
84+ server = " https://develocity.apache.org"
85+ projectId = " polaris"
86+ buildScan {
87+ uploadInBackground = ! isCI
88+ publishing.onlyIf {
89+ // TODO temporarily disabled until the necessary secrets are present for the polaris-tools
90+ // repo
91+ // it.isAuthenticated
92+ false
93+ }
94+ obfuscation { ipAddresses { addresses -> addresses.map { _ -> " 0.0.0.0" } } }
95+ }
96+ } else {
97+ // In all other cases, especially PR CI runs, use Gradle's public Develocity instance.
98+ var cfgPrjId: String? = System .getenv(" DEVELOCITY_PROJECT_ID" )
99+ projectId = if (cfgPrjId == null || cfgPrjId.isEmpty()) " polaris" else cfgPrjId
100+ buildScan {
101+ val isGradleTosAccepted = " true" == System .getenv(" GRADLE_TOS_ACCEPTED" )
102+ val isGitHubPullRequest = gitHubRef?.startsWith(" refs/pull/" ) ? : false
103+ if (isGradleTosAccepted || (isCI && isGitHubPullRequest && isApachePolarisGitHub)) {
104+ // Leave TOS agreement to the user, if not running in CI.
105+ termsOfUseUrl = " https://gradle.com/terms-of-service"
106+ termsOfUseAgree = " yes"
107+ }
108+ System .getenv(" DEVELOCITY_SERVER" )?.run {
109+ if (isNotEmpty()) {
110+ server = this
111+ }
112+ }
113+ if (isGitHubPullRequest) {
114+ System .getenv(" GITHUB_SERVER_URL" )?.run {
115+ val ghUrl = this
116+ val ghRepo = System .getenv(" GITHUB_REPOSITORY" )
117+ val prNumber = gitHubRef!! .substringAfter(" refs/pull/" ).substringBefore(" /merge" )
118+ link(" GitHub pull request" , " $ghUrl /$ghRepo /pull/$prNumber " )
119+ }
120+ }
121+ uploadInBackground = ! isCI
122+ publishing.onlyIf { isCI || gradle.startParameter.isBuildScan }
123+ obfuscation { ipAddresses { addresses -> addresses.map { _ -> " 0.0.0.0" } } }
124+ }
125+ }
126+ }
0 commit comments