From e26f9d92e2244947b12cf17507cc4ae275f58c15 Mon Sep 17 00:00:00 2001 From: nacho Date: Mon, 11 Dec 2023 15:15:54 +0100 Subject: [PATCH] improve docs --- gradle/Earthfile | 3 +-- gradle/README.md | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gradle/Earthfile b/gradle/Earthfile index 3a84643..1753241 100644 --- a/gradle/Earthfile +++ b/gradle/Earthfile @@ -12,8 +12,7 @@ VERSION --global-cache 0.7 GRADLE_GET_MOUNT_CACHE: COMMAND ARG EARTHLY_TARGET_PROJECT_NO_TAG - ARG OS_RELEASE=$(md5sum /etc/os-release | cut -d ' ' -f 1) - ARG cache_prefix = "${EARTHLY_TARGET_PROJECT_NO_TAG}#${OS_RELEASE}#earthly-gradle-cache" + ARG cache_prefix = "${EARTHLY_TARGET_PROJECT_NO_TAG}#earthly-gradle-cache" IF [ "$GRADLE_USER_HOME" = "" ] ENV GRADLE_USER_HOME="$HOME/.gradle" END diff --git a/gradle/README.md b/gradle/README.md index d8054b8..c1c283e 100644 --- a/gradle/README.md +++ b/gradle/README.md @@ -11,18 +11,23 @@ IMPORT github.com/earthly/lib/gradle: AS gradle ## +GRADLE_GET_MOUNT_CACHE -This function sets the following entries in the calling environment, so they can be used later on `RUN` commands -- `$EARTHLY_GRADLE_USER_HOME_CACHE`: Code of the mount cache for the gradle home. -- `$EARTHLY_GRADLE_PROJECT_CACHE`: Code of the mount cache for the .gradle folder. +This function sets the following entries in the calling environment, so they can be used later to parametrize two global mount caches in `RUN` commands: +- `$EARTHLY_GRADLE_USER_HOME_CACHE`: Code of the mount cache for the [gradle user home](https://docs.gradle.org/current/userguide/directory_layout.html#dir:gradle_user_home) directory. +- `$EARTHLY_GRADLE_PROJECT_CACHE`: Code of the mount cache for the [gradle project root](https://docs.gradle.org/current/userguide/directory_layout.html#dir:project_root) directory. -### Arguments: +### Arguments - `cache_prefix`: To be used in both caches. By default: `${EARTHLY_TARGET_PROJECT_NO_TAG}#${OS_RELEASE}#earthly-gradle-cache` -### Example: +### Example ```earthly DO gradle+GRADLE_GET_MOUNT_CACHE RUN --mount=$EARTHLY_GRADLE_USER_HOME_CACHE --mount=$EARTHLY_GRADLE_PROJECT_CACHE gradle --no-daemon build ``` +### Scoping + +If `cache_prefix` is not set, the two global caches have an Earthfile-scope, that is, they are not shared with other Earthfiles. +Otherwise, all Earthfiles using the same `cache_prefix` will share the cache mounts. + ## Example See [earthly-intellij-plugin](https://github.com/earthly/earthly-intellij-plugin/blob/main/Earthfile) for a complete example. \ No newline at end of file