sbt-develocity v1.1 ships with local and remote build cache support for the `compile` and `test` tasks (see https://gradle.com/develocity/releases/2024.2#build-caching-for-sbt). The local build cache is enabled by default, while the remote cache requires configuring the nodes that are allowed to upload artifacts to the build cache (see https://docs.gradle.com/develocity/sbt-build-cache/#rolling_out_the_cache_in_your_organization). It's important to confirm that a project's build is ready to use the build cache (local or remote) to avoid unexpected behaviors. Specifically, one should make sure that all relevant inputs to the `compile` or `test` task are captured, as otherwise the generated build cache key will be incorrect (this can lead to erractic behavior, as entries from the cache will be reused when they shouldn't). Refer to https://docs.gradle.com/enterprise/sbt-plugin/#caching_the_compile_task to know what are the build cache inputs captured for the `compile` task and https://docs.gradle.com/enterprise/sbt-plugin/#caching_the_test_testonly_and_testquick_tasks for the `test` task. This commits disables the local build cache so that a proper rollout can be planned (see https://docs.gradle.com/develocity/sbt-build-cache/#rolling_out_the_cache_in_your_organization). Co-authored-by: Mirco Dotta <mdotta@gradle.com>
81 lines
3.1 KiB
Scala
81 lines
3.1 KiB
Scala
/*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
* (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import com.gradle.develocity.agent.sbt.DevelocityPlugin
|
|
import com.gradle.develocity.agent.sbt.DevelocityPlugin.autoImport.{
|
|
develocityConfiguration,
|
|
FlakyTestPolicy,
|
|
ProjectId,
|
|
Publishing
|
|
}
|
|
import sbt.{ inConfig, url, AutoPlugin, Def, PluginTrigger, Plugins, Setting }
|
|
import sbt.Keys.insideCI
|
|
|
|
object PekkoDevelocityPlugin extends AutoPlugin {
|
|
|
|
private val ApacheDevelocityUrl = url("https://ge.apache.org")
|
|
private val PekkoProjectId = ProjectId("pekko")
|
|
private val ObfuscatedIPv4Address = "0.0.0.0"
|
|
|
|
override lazy val trigger: PluginTrigger = allRequirements
|
|
override lazy val requires: Plugins = DevelocityPlugin
|
|
|
|
override lazy val buildSettings: Seq[Setting[_]] = Def.settings(
|
|
develocityConfiguration := {
|
|
val isInsideCI = insideCI.value
|
|
|
|
val original = develocityConfiguration.value
|
|
val apacheDevelocityConfiguration =
|
|
original
|
|
.withProjectId(PekkoProjectId)
|
|
.withServer(
|
|
original.server
|
|
.withUrl(Some(ApacheDevelocityUrl))
|
|
.withAllowUntrusted(false))
|
|
.withBuildScan(
|
|
original.buildScan
|
|
.withPublishing(Publishing.onlyIf(_.authenticated))
|
|
.withBackgroundUpload(!isInsideCI)
|
|
.withObfuscation(
|
|
original.buildScan.obfuscation
|
|
.withIpAddresses(_.map(_ => ObfuscatedIPv4Address))))
|
|
.withBuildCache(
|
|
original.buildCache
|
|
.withLocal(
|
|
original.buildCache.local
|
|
.withEnabled(false)))
|
|
if (isInsideCI) {
|
|
apacheDevelocityConfiguration
|
|
.withTestRetryConfiguration(
|
|
original.testRetryConfiguration
|
|
.withMaxRetries(1)
|
|
.withFlakyTestPolicy(FlakyTestPolicy.Fail) // preserve the original build outcome in case of flaky tests
|
|
)
|
|
} else apacheDevelocityConfiguration
|
|
})
|
|
}
|
|
|
|
/**
|
|
* An AutoPlugin to add Develocity test configuration to the TestJdk9 configuration.
|
|
*/
|
|
object PekkoDevelocityJdk9TestSettingsPlugin extends AutoPlugin {
|
|
override lazy val trigger: PluginTrigger = allRequirements
|
|
override lazy val requires: Plugins = DevelocityPlugin && Jdk9
|
|
|
|
// See https://docs.gradle.com/develocity/sbt-plugin/#enabling_build_cache_in_a_custom_sbt_configuration
|
|
override lazy val projectSettings = DevelocityPlugin.develocitySettings(Jdk9.TestJdk9)
|
|
}
|