@@ -6,6 +6,8 @@ import ScaladocGeneration._
66import com .jsuereth .sbtpgp .PgpKeys
77import sbt .Keys .*
88import sbt .*
9+ import sbt .nio .FileStamper
10+ import sbt .nio .Keys .*
911import complete .DefaultParsers ._
1012import pl .project13 .scala .sbt .JmhPlugin
1113import pl .project13 .scala .sbt .JmhPlugin .JmhKeys .Jmh
@@ -281,6 +283,8 @@ object Build {
281283
282284 val fetchScalaJSSource = taskKey[File ](" Fetch the sources of Scala.js" )
283285
286+ val extraDevelocityCacheInputFiles = taskKey[Seq [Path ]](" Extra input files for caching" )
287+
284288 lazy val SourceDeps = config(" sourcedeps" )
285289
286290 // Settings shared by the build (scoped in ThisBuild). Used in build.sbt
@@ -351,6 +355,7 @@ object Build {
351355 buildCache
352356 .withLocal(buildCache.local.withEnabled(true ).withStoreEnabled(true ))
353357 .withRemote(buildCache.remote.withEnabled(true ).withStoreEnabled(isInsideCI))
358+ .withRequireClean(! isInsideCI)
354359 )
355360 .withTestRetry(
356361 config.testRetry
@@ -363,6 +368,8 @@ object Build {
363368 // Deactivate Develocity's test caching because it caches all tests or nothing.
364369 // Also at the moment, it does not take compilation files as inputs.
365370 Test / develocityBuildCacheClient := None ,
371+ extraDevelocityCacheInputFiles := Seq .empty,
372+ extraDevelocityCacheInputFiles / outputFileStamper := FileStamper .Hash ,
366373 )
367374
368375 // Settings shared globally (scoped in Global). Used in build.sbt
@@ -443,7 +450,17 @@ object Build {
443450 Compile / packageBin / packageOptions +=
444451 Package .ManifestAttributes (
445452 " Automatic-Module-Name" -> s " ${dottyOrganization.replaceAll(" -" ," ." )}. ${moduleName.value.replaceAll(" -" ," ." )}"
446- )
453+ ),
454+
455+ // add extraDevelocityCacheInputFiles in cache key components
456+ Compile / compile / buildcache.develocityTaskCacheKeyComponents +=
457+ (Compile / extraDevelocityCacheInputFiles / outputFileStamps).taskValue,
458+ Test / test / buildcache.develocityTaskCacheKeyComponents +=
459+ (Test / extraDevelocityCacheInputFiles / outputFileStamps).taskValue,
460+ Test / testOnly / buildcache.develocityInputTaskCacheKeyComponents +=
461+ (Test / extraDevelocityCacheInputFiles / outputFileStamps).taskValue,
462+ Test / testQuick / buildcache.develocityInputTaskCacheKeyComponents +=
463+ (Test / extraDevelocityCacheInputFiles / outputFileStamps).taskValue
447464 )
448465
449466 // Settings used for projects compiled only with Java
@@ -612,8 +629,8 @@ object Build {
612629 },
613630 Compile / doc / scalacOptions ++= scalacOptionsDocSettings(),
614631 // force recompilation of bootstrapped modules when the compiler changes
615- Compile / compile / buildcache.develocityTaskCacheKeyComponents +=
616- (`scala3-compiler` / Compile / compile / buildcache.develocityTaskCacheKey).taskValue
632+ Compile / extraDevelocityCacheInputFiles + +=
633+ (`scala3-compiler` / Compile / fullClasspathAsJars).value.map(_.data.toPath)
617634 )
618635
619636 lazy val commonBenchmarkSettings = Seq (
0 commit comments