Skip to content

Allow caching arbitrary directories during build #44

@docent

Description

@docent

In order to facilitate at least partially incremental builds in Gradle, it would be good to cache some data between builds. One way to do that would be to utilize Gradle's Build Cache but that's a more advanced approach which requires that the tasks support caching. (I suppose build cache support could be added to this buildback at some point, as an option)

For now I propose creating a "mirror" of cached directories under $CACHE_DIR/.gradle-additional-cache-dirs by creating corresponding symlinks, if the environmental variable $GRADLE_ADDITIONAL_CACHE_DIRS is set. The variable would contain relative directories to be cached, separated by :, e.g. build:src/main/frontend/node_modules

Some caveats:

  • This solution is not perfect, as, in many cases, Gradle's up-to-date checks rely on absolute paths, which are, unfortunately, different on every Heroku build. But it's still a step forward.
  • No directories with : in directory name (same limitation as with, e.g. $PATH variable
  • No validation whatsoever (e.g. nested directories, etc.)

Code in this commit. I can create a PR if necessary.

This also solves #19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions