use of org.gradle.caching.BuildCacheKey in project gradle by gradle.
the class DefaultBuildCacheController method store.
@Override
public void store(final BuildCacheStoreCommand command) {
boolean anyStore = local.canStore() || legacyLocal.canStore() || remote.canStore();
if (!anyStore) {
return;
}
final BuildCacheKey key = command.getKey();
final Pack pack = new Pack(command);
tmp.withTempFile(command.getKey(), new Action<File>() {
@Override
public void execute(File file) {
pack.execute(file);
if (legacyLocal.canStore()) {
legacyLocal.store(key, new StoreTarget(file));
}
if (remote.canStore()) {
remote.store(key, new StoreTarget(file));
}
if (local.canStore()) {
local.store(key, file);
}
}
});
}
use of org.gradle.caching.BuildCacheKey in project gradle by gradle.
the class DefaultBuildCacheController method loadRemoteAndStoreResultLocally.
private Optional<BuildCacheLoadResult> loadRemoteAndStoreResultLocally(BuildCacheKey key, CacheableEntity entity) {
if (!remote.canLoad()) {
return Optional.empty();
}
AtomicReference<Optional<BuildCacheLoadResult>> result = new AtomicReference<>(Optional.empty());
tmp.withTempFile(key, file -> {
Optional<BuildCacheLoadResult> remoteResult;
try {
remoteResult = remote.maybeLoad(key, file, f -> packExecutor.unpack(key, entity, f));
} catch (Exception e) {
throw new GradleException("Could not load from remote cache: " + e.getMessage(), e);
}
if (remoteResult.isPresent()) {
local.maybeStore(key, file);
result.set(remoteResult);
}
});
return result.get();
}
Aggregations