This message was deleted.
# plugin-development
s
This message was deleted.
a
Gradle can't know that your task is independent if you use the same output locations. That is why it complains due to possible correctness issues. Basically Gradle can't know what task should run first. You can force the order of tasks with "mustRunAfter" and then Gradle won't complain (I believe full error message hints on that). Usually an even better solution is, to write to a different output location. Normally, you don't need to share the same output folder. And with that you also get all the performance benefits, e.g. with configuration caching, Gradle can run these tasks in parallel without collisions
v
Or you don't use
@OutputDirectory
, but individual output files, then they can also land in the same directory.
i
What if, • there is a first task called
:a
. It creates files in
build/a
. • there is a second task called
:b
. It depends on
:a
, and creates a subfolder in
build/a
. • I would like to create a task
:custom
that works on the outputs of
:a
, which doesn't need anything from
:b
.
:b
is very slow, so I do not want
:custom
to depend on it. Following the tips from other people in this channel, I created an intermediate
Copy
task that copies
build/a
to
build/custom
, so
:custom
works in its own folder. However, Gradle still complains that
build/a
is created by
:b
, and
:custom
should depend on it.
a
However, Gradle still complains that
build/a
is created by
:b
, and
:custom
should depend on it.
You don't need dependency, but you just have to specifiy at least the order relation. So if you don't want for
:custom
to depend on
:b
, you can set the order with
mustRunAfter
and that should solve the issue. E.g.: you set
:custom mustRunAfter :b
or
:b mustRunAfter :custom
. I guess second is better, since
b
is slow. That way tasks won't depend on each other. So when you run just :custom, it won't run also :b . But they won't run in parallel with cc. Another option is that you try to depend/output only invidiual output files and not whole folder (or whole task a) as Vampire suggested
v
Even defining an order constraint would not be sufficient. It would care about the warning, but not the problem. For example, you run
:a
, then you run
:b
. Then you run
:a
again and it will not be up-to-date, as
:a
declares the whole
build/a
as output directory, so it sees its outputs were changed and runs again. If caching is enabled, it would be even worse, because then - except if
:a
clears out
build/a
in the beginning - the file gernerated by
:b
would now be considered
:a
outputs too and stored in the cache entry. You should really avoid having overlapping outputs.
šŸ‘ 1
Also, the intermediate copy task would not help much in the way you described, because the copy task should now be the one complained about, that it uses
:b
output without ordering constraint. What was maybe meant was a copy task that copies the
:a
files to a separate directory and use that to run
:b
, not
:custom
. Besides that a copy task is rarely what you want, but usually a sync task, it probably wouldn't help either though. You would probably not get the warning, as there is then a dependency between
:custom
and
:b
but you would again write to the output dir or
:custom
in
:b
and thus would disturb up-to-date checks.
i
I see, I understand. The problem is I want the outputs of task
:a
without `:b`'s changes, and I don't control the fact that they use the same directory :/
v
Then you should complain to the one controlling that fact. šŸ™‚
i
Thanks, I will šŸ˜…
Also, I didn't know about Sync, indeed it would be better in this situation, thanks
I guess my best bet is to explicitly specify each file I'm interested in in `:a`'s outputs, but there are a lot of different kinds of files so it's easier said than done :/