Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
idelvall committed Dec 11, 2023
1 parent 40a4041 commit e26f9d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions gradle/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ IMPORT github.com/earthly/lib/gradle:<version/commit> 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.

0 comments on commit e26f9d9

Please sign in to comment.