Hello, I'm planning to create a pre-compilation st...
# community-support
a
Hello, I'm planning to create a pre-compilation step that can be reused in later CI stages for building and testing (build & test are in the same CI stage). What's the ideal way to achieve this with Gradle? • Is there a recommended approach to compile the project once and use the result in multiple CI stages (e.g., using a shared build cache)? • Would this provide significant benefits in terms of CI performance or stability? • Are there any pitfalls I should be aware of? For additional context: we publish the Gradle build cache once a day (every night), but this pre-compiled result is intended to be reused across stages within the same commit-based pipeline run.
āž• 1
v
Do the steps run on the same worktree, or do you re-clone in the separate steps?
šŸ‘† 1
And do the steps run on the same build machine / agent, or does each step has a vanilla operating system state?
a
Pre-compilation, build, and test run have the same worktree (same head) but in different runners
t
So different worktrees (in Git terms: https://git-scm.com/docs/gitglossary#def_worktree)
In that case, you'd want to copy the build state (or the build cache), and probably the various Gradle caches (dependencies, configuration cache, etc.) between runners (attach them as "artifacts" of each stage, retrieved by the next stage)
a
got it is this enough? or should I also bring some dirs inside
build
dirs?
Copy code
.gradle/caches/modules-2
.gradle/wrapper
v
What you can bring over also depends on whether the runners are identical in terms of paths, as some things contain absolute paths. So if the runners are identical and you also have the worktree in the exact same place, you can probably bring over everything needed. But what you just posted will most probably not be enough. Especially the state within the project and so on. It also depends on your project, if for example the pre-compilation step is cacheable and you enabled the cache, then you could just bring over the build cache and the subsequent runs can take the result from the cache. If not, you probably need to bring over your
build
directory or whatever your build writes to in your project. And probably also additional other things so that Gradle does not think those files are stale, .....
āž• 1
a
Thank you so much, I will explore this
šŸ‘Œ 1