Hi folks. I'm refactoring some custom code generat...
# caching
k
Hi folks. I'm refactoring some custom code generation tasks written by someone who didn't understand task outputs and cacheability. Task A writes to
generated/com/acme/_generated
exclusively. Task B's writes to a dynamic list of output directories like
generated/com/...
and
generated/foo/...
. But when the output contains
generated/com
, we have a conflict with Task A and caching is disabled due to overlapping outputs. What I'd like to do is configure outputs for Task B to say it outputs to
generated/com/... excluding generated/com/acme/_generated
... I doubt this is possible though. Any ideas?
e
I think a cleaner pattern is to have Task A write to something like
taskA/generated/com/acme/_generated
, and Task B write to
taskB/generated/com
, then have a sync task that combines the output beneath
generated/
k
Yes, I was thinking the same thing. Have purely isolated outputs for A and B, then use Sync (maybe with some
preserve
patterns) to merge back to the destination.
Ooh I can also set the duplicatesStrategy to FAIL (at least when testing) - that will ensure nothing is silently overwritten
v
Imho you should never set any duplicates strategy. Not setting is also failing, so if setting that only to fail but never to anything else. I have not yet seen a single use-case where setting one was not symptom treatment where better the reason is fixed. Regarding copying together, why do you need that? Just make sure the tasks generate to dedicated output directories and configure the tasks (or a provider thereof) as
srcDir
, then every task that properly requests sources like source jar, compilation, static code analyzer, ..... will get the sources wherever they were generated to and also have the necessary task dependency automatically as it should be. 🙂
k
I agree with the copying together - unfortunately it's a legacy enterprise product and changing the structure around would have consequences beyond just the build process itself. So the
Sync
task is a good workaround. Thinking about DuplicatesStrategy, I think I definitely want it to fail while I'm testing this.
👌 1
v
As I said, imho you definitely always want it to fail 🙂
k
Yes, ah I see now. Fail is the default, yes?
v
The default is fail and suggest to set any.
So yeah, set FAIL everwhere that noone gets the idea to set anything else 😄
k
danke
v
Immer gerne 🙂