How to clean build cache?

Hi Gradle Community,

I apologize if this is a trivial question.

Is it possible to tell Gradle to clear build cache and build everything from scratch (e.g. gradle --clear-build-cache)? There’s an option to manually remove the cache folder but that seems so hacky and “gradle clean” only removes the build folder. There’s a --no-build-cache option, but that’s just to tell the current build not to use the build cache.

Thank you.

Hi Kevin,

there currently isn’t a built-in solution for removing the local build cache folder. What is your use-case for removing the folder? Do you have a bad artifact in there?

Cheers,
Stefan

Hi Stefan,

We would like to do a clean build especially when deploying to production and avoid the possibility of re-using existing bad artifacts. In a perfect world, there is no bad artifacts, but anything can happen will happen.

Hi Kevin,

you can disable the build cache when deploying to production. Though if you are using the build cache in all the other builds, I suggest you also use it when deploying to production, since those are the artifacts you actually tested.

If you really don’t want to use anything from any cache and still upload to the build cache, you can also use --rerun-tasks, though I really suggest you run the build as you do in all of your other builds.

Cheers,
Stefan