Skip to content

Commit bef520f

Browse files
authored
Activate Develocity's Build Cache (#22523)
1 parent df6958b commit bef520f

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

project/Build.scala

+15-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import complete.DefaultParsers._
1010
import pl.project13.scala.sbt.JmhPlugin
1111
import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh
1212
import com.gradle.develocity.agent.sbt.DevelocityPlugin.autoImport._
13+
import com.gradle.develocity.agent.sbt.api.experimental.buildcache
1314
import com.typesafe.sbt.packager.Keys._
1415
import com.typesafe.sbt.packager.MappingsHelper.directory
1516
import com.typesafe.sbt.packager.universal.UniversalPlugin
@@ -339,24 +340,27 @@ object Build {
339340
buildScan
340341
.withPublishing(Publishing.onlyIf(_.authenticated))
341342
.withBackgroundUpload(!isInsideCI)
342-
.tag(if (isInsideCI) "CI" else "Local")
343+
.withTag(if (isInsideCI) "CI" else "Local")
343344
.withLinks(buildScan.links ++ GithubEnv.develocityLinks)
344345
.withValues(buildScan.values ++ GithubEnv.develocityValues)
345346
.withObfuscation(buildScan.obfuscation.withIpAddresses(_.map(_ => "0.0.0.0")))
346347
)
347348
.withBuildCache(
348349
buildCache
349-
.withLocal(buildCache.local.withEnabled(false))
350-
.withRemote(buildCache.remote.withEnabled(false))
350+
.withLocal(buildCache.local.withEnabled(true).withStoreEnabled(true))
351+
.withRemote(buildCache.remote.withEnabled(true).withStoreEnabled(isInsideCI))
351352
)
352-
.withTestRetryConfiguration(
353-
config.testRetryConfiguration
353+
.withTestRetry(
354+
config.testRetry
354355
.withFlakyTestPolicy(FlakyTestPolicy.Fail)
355356
.withMaxRetries(if (isInsideCI) 1 else 0)
356357
.withMaxFailures(10)
357358
.withClassesFilter((className, _) => !noRetryTestClasses.contains(className))
358359
)
359-
}
360+
},
361+
// Deactivate Develocity's test caching because it caches all tests or nothing.
362+
// Also at the moment, it does not take compilation files as inputs.
363+
Test / develocityBuildCacheClient := None,
360364
)
361365

362366
// Settings shared globally (scoped in Global). Used in build.sbt
@@ -604,7 +608,10 @@ object Build {
604608
assert(docScalaInstance.loaderCompilerOnly == base.loaderCompilerOnly)
605609
docScalaInstance
606610
},
607-
Compile / doc / scalacOptions ++= scalacOptionsDocSettings()
611+
Compile / doc / scalacOptions ++= scalacOptionsDocSettings(),
612+
// force recompilation of bootstrapped modules when the compiler changes
613+
Compile / compile / buildcache.develocityTaskCacheKeyComponents +=
614+
(`scala3-compiler` / Compile / compile / buildcache.develocityTaskCacheKey).taskValue
608615
)
609616

610617
lazy val commonBenchmarkSettings = Seq(
@@ -1015,10 +1022,6 @@ object Build {
10151022
sjsSources
10161023
} (Set(scalaJSIRSourcesJar)).toSeq
10171024
}.taskValue,
1018-
1019-
// Develocity's Build Cache does not work with our compilation tests
1020-
// at the moment: it does not take compilation files as inputs.
1021-
Test / develocityBuildCacheClient := None,
10221025
)
10231026

10241027
def insertClasspathInArgs(args: List[String], cp: String): List[String] = {
@@ -1117,7 +1120,7 @@ object Build {
11171120
libraryDependencies += "org.scala-lang" % "scala-library" % stdlibVersion,
11181121
(Compile / scalacOptions) ++= Seq(
11191122
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
1120-
"-sourcepath", (Compile / sourceDirectories).value.map(_.getAbsolutePath).distinct.mkString(File.pathSeparator),
1123+
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
11211124
"-Yexplicit-nulls",
11221125
),
11231126
(Compile / doc / scalacOptions) ++= ScaladocConfigs.DefaultGenerationSettings.value.settings,

project/plugins.sbt

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ addSbtPlugin("ch.epfl.scala" % "sbt-tasty-mima" % "1.0.0")
2222

2323
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")
2424

25-
addSbtPlugin("com.gradle" % "sbt-develocity" % "1.1.1")
25+
addSbtPlugin("com.gradle" % "sbt-develocity" % "1.1.2")
26+
27+
resolvers +=
28+
"Develocity Artifactory" at "https://repo.grdev.net/artifactory/public/"
29+
30+
addSbtPlugin("com.gradle" % "sbt-develocity" % "1.2-rc-2")

0 commit comments

Comments
 (0)