-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow caching arbitrary directories during build #44
Comments
@docent thanks for pulling this together. In general, I like this approach. but a few concerns come to mind:
So we might actually need a different mechanism for each of these. I think we should just cache the But then I think you should keep the What do you think? |
@jkutner Yeah, you are right about the The way I solved it for my example (Spring Boot) project was this:
So basically my stage task copies the uber-jar to the Now, of course, we cannot anticipate all the possible usages that come to people's minds. Someone might have a project where the entire Also, bear in mind that people might change the build directory from within their Gradle configuration files. Again, this is rather atypical, albeit possible. Speaking of |
I definitely don't want to remove the build dir from the slug by default. Lots of non-Spring-Boot apps need stuff from it (for example, Ratpack writes a I think copying the build dir into the cache is fine. We do this for the Scala buildpack. It adds a small amount of time to the build, but it's probably worth the gain from incremental compile. |
@jkutner I did some more tests and, unfortunately, achieving incremental builds might be difficult with current Heroku build system, which makes a new, differently named directory for each build. Even if we link or copy
That's because in many cases Gradle uses absolute paths for up-to-date checks. The only way I was able to achieve almost incremental builds was by setting build directory via To sum up:
|
@docent in the Scala buildpack we move everything into a consistently named directory, but I have to say that I would be weary of doing this with Gradle by default. It's hard to maintain (notice the So yea, maybe we should put incremental compile aside for now. This issue is about cached dirs anyways :) the Scala buildpack again has a good example (albeit not configurable). The question would be what env var to use. I think |
@jkutner Yeah, I think GRADLE_CACHED_DIRS would be good. I just hope it conveys the intent well - Gradle has build cache and it would be bad if ppl confused that |
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:
:
in directory name (same limitation as with, e.g.$PATH
variableCode in this commit. I can create a PR if necessary.
This also solves #19
The text was updated successfully, but these errors were encountered: