-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds save & restore gradle dependency cache scripts (#25)
* Adds save & restore gradle dependency cache scripts * Add backticks to comments in restore & save gradle dependency cache scripts Co-authored-by: Gio Lodi <giovanni.lodi42@gmail.com> Co-authored-by: Gio Lodi <giovanni.lodi42@gmail.com>
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -eu | ||
|
||
# The key is shared with `bin/save_gradle_dependency_cache` | ||
GRADLE_DEPENDENCY_CACHE_KEY="GRADLE_DEPENDENCY_CACHE" | ||
|
||
echo "Restoring Gradle dependency cache..." | ||
|
||
# `save_cache` & `restore_cache` scripts only work if they are called from the same directory | ||
pushd "$GRADLE_RO_DEP_CACHE_BASE_FOLDER" | ||
restore_cache "$GRADLE_DEPENDENCY_CACHE_KEY" | ||
popd | ||
|
||
echo "---" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash -eu | ||
|
||
# The key is shared with `bin/restore_gradle_dependency_cache` | ||
GRADLE_DEPENDENCY_CACHE_KEY="GRADLE_DEPENDENCY_CACHE" | ||
|
||
echo "Saving Gradle dependency cache..." | ||
|
||
mkdir -p "$GRADLE_RO_DEP_CACHE" | ||
|
||
# https://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_copy | ||
# Gradle suggests removing the `*.lock` files and the `gc.properties` file before saving cache | ||
cp -r ~/.gradle/caches/modules-2 "$GRADLE_RO_DEP_CACHE" \ | ||
&& find "$GRADLE_RO_DEP_CACHE" -name "*.lock" -type f -delete \ | ||
&& find "$GRADLE_RO_DEP_CACHE" -name "gc.properties" -type f -delete | ||
|
||
# `save_cache` & `restore_cache` scripts only work if they are called from the same directory | ||
pushd "$GRADLE_RO_DEP_CACHE_BASE_FOLDER" | ||
# For now we are using a single key - we might expand on this later by using dependency catalog version | ||
save_cache "$GRADLE_RO_DEP_CACHE_FOLDER_NAME" "$GRADLE_DEPENDENCY_CACHE_KEY" --force | ||
popd | ||
|
||
echo "---" |