-
Notifications
You must be signed in to change notification settings - Fork 950
Make remoteCacheId content-based #6026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
remoteCacheId := { | ||
val compileExtraInc = (Compile / extraIncOptions).value | ||
val compileInputs = (Compile / unmanagedSources / inputFileStamps).value | ||
val compileCp = (Compile / externalDependencyClasspath / outputFileStamps).value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be defined at the configuration level (and combined at the project level via a scope filter), so that other configurations such as IntegrationTest can more easily be supported?
sbt/main/src/main/scala/sbt/internal/RemoteCache.scala
Lines 206 to 207 in 5a960f2
) ++ inConfig(Compile)(packageCacheSettings(compileArtifact(Compile, cachedCompileClassifier))) | |
++ inConfig(Test)(packageCacheSettings(testArtifact(Test, cachedTestClassifier)))) |
Seq[Def.Setting[_]]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'm hoping I can eventually implement pullRemoteCache
at the configuration level.
Refactor remote caching to be scoped to configuration. In addition, this avoid the use of dependency resolver (since I'm not resolving anything) and directly invoke the Ivy resolver for the artifact, somewhat analogus to publishing process. This should speed up the `pullRemoteCache` since it avoids the POM download as well. For sbt-binrary-remote-cache this created a bit of complication since the (publishing) resolver doesn't act correctly as (downloading) resolver in terms of the credentials, so I had to create a new key `remoteCacheResolvers` to have asymmetric resolver.
Fixes sbt#6102 sbt#6026 changed the implementation of remote cache to NOT use dependency resolution (Coursier), and directly use Ivy resolver for efficiency. This was good, but when I made the change, I've changed the cache directory to be `crossTarget.value / "remote-cache"`. This was ok for local testing purpose, but not great for real usage since we don't want the cache to be wiped out either in the CI machines or on a local laptop. This adds a new Global key called `localCacheDirectory`. Similar to Coursier cache, this is meant to be shared across all builds running on a machine. Also similar to Coursier cache this will try to follow the operating system specifc caching directory. ### localCacheDirectory location - Environment variable: `SBT_LOCAL_CACHE` - System property: `sbt.global.localcache` - Windows: %LOCALAPPDATA%\sbt\v1 - macOS: $HOME/Library/Caches/sbt/v1 - Linux: $HOME/.cache/sbt/v1
Fixes sbt#6102 sbt#6026 changed the implementation of remote cache to NOT use dependency resolution (Coursier), and directly use Ivy resolver for efficiency. This was good, but when I made the change, I've changed the cache directory to be `crossTarget.value / "remote-cache"`. This was ok for local testing purpose, but not great for real usage since we don't want the cache to be wiped out either in the CI machines or on a local laptop. This adds a new Global key called `localCacheDirectory`. Similar to Coursier cache, this is meant to be shared across all builds running on a machine. Also similar to Coursier cache this will try to follow the operating system specifc caching directory. ### localCacheDirectory location - Environment variable: `SBT_LOCAL_CACHE` - System property: `sbt.global.localcache` - Windows: %LOCALAPPDATA%\sbt\v1 - macOS: $HOME/Library/Caches/sbt/v1 - Linux: $HOME/.cache/sbt/v1
Fixes #5842
Using Git commit for remote caching id was one of the first things people think about, but it doesn't scale because that means you're downloading all module JARs all the time anytime anyone adds a commit. The basis of remote caching is that people are adding commits to many subprojects, so that's bad.
As an alternative, this uses content hash of input files and external dependency JARs.
remoteCacheId
,pushRemoteCache
, andpullRemoteCache
are now scoped to configuration (Compile
andTest
). Since we're not resolving any version conflicts, dependency resolver is no longer used and the artifacts are directly downloaded from the Ivy resolver. This should speed up thepullRemoteCache
since it avoids the POM download as well.note
For sbt-binrary-remote-cache this created a bit of complication since the (publishing) resolver doesn't act correctly as (downloading) resolver in terms of the credentials, so I had to create a new key
remoteCacheResolvers
to have asymmetric resolver.