Vlastimil Brecka
06/22/2026, 2:42 PM./gradlew clean build
is running clean first guaranteed? I always though this "single gradlew invocation with multiple tasks" syntax means to merge the tasks graphs and run as it makes sense - i.e. the exactly same thing as if I created a explicit task which dependsOn clean, build
but this doesn't seem to be the case as I'm trying it
is it guaranteed?Tim Yates
06/22/2026, 2:45 PMGradle will execute the build as quickly as possible, it will also respect the safety of the order of tasks specified on the command line and ensure thatruns beforecleanwhen specified in that order.build
Vlastimil Brecka
06/22/2026, 2:54 PMgradlew a b, where a and b depend on c)
i.e. youre saying it will execute c first then a before b because order - and if it were a plain task, a-b ordering is undeterministic?)Thomas Broyer
06/22/2026, 3:15 PMa before b then that's what Gradle will do; otherwise it will execute b first.Vlastimil Brecka
06/22/2026, 3:20 PMc twice?Vampire
06/22/2026, 3:24 PMVampire
06/22/2026, 3:24 PMVlastimil Brecka
06/22/2026, 3:25 PMdependsOn listVampire
06/22/2026, 3:25 PMclean should actually run before most other tasks automatically anyway, as it has a @Destroys or what it was called for the stuff other tasks generate so should run first.Vampire
06/22/2026, 3:25 PMclean build is a bad habit you bring over from Maven and that you should never do with Gradle.Vampire
06/22/2026, 3:26 PMVampire
06/22/2026, 3:26 PMVampire
06/22/2026, 3:27 PMclean then you eradicate current outputs, so all work needs to be redone.Vlastimil Brecka
06/22/2026, 3:27 PMVampire
06/22/2026, 3:27 PMclean is just wasting timeVampire
06/22/2026, 3:28 PMThomas Broyer
06/22/2026, 3:28 PMokay good to know, I always though its just cli level syntax forMore or less yes, with an additionallistdependsOn
b.shouldRunAfter(a) to maintain order if possibleVampire
06/22/2026, 3:28 PMVlastimil Brecka
06/22/2026, 3:28 PMVlastimil Brecka
06/22/2026, 3:29 PMVampire
06/22/2026, 3:29 PMVampire
06/22/2026, 3:29 PMVlastimil Brecka
06/22/2026, 3:30 PMVampire
06/22/2026, 3:30 PMVampire
06/22/2026, 3:31 PMgit clean -fdx to remove everything not checked in.Vampire
06/22/2026, 3:32 PMclean could still not clean everything, depending on the build, unless you know for sure clean does throw everything away.
But actually it typically does not, but only throws away the build directory.Vlastimil Brecka
06/22/2026, 3:35 PMRyan Schmitt
06/23/2026, 3:34 PMgit clean -fdx, but I always review the output of git clean -ndx first. git clean -fdx is one of the most destructive git invocations, since it can delete untracked files. A slightly safer alternative is git clean -fdX, which deletes ignored files onlyVampire
06/23/2026, 3:42 PM-i to clean is nice as you can then filter some things out manually that should not be cleaned.Vampire
06/23/2026, 3:44 PMjj command was run.