Invalidate build if build.gradle configuration was changed

I don’t know if there is an idea behind, but it looks looks like a huge bug. When I change some build scripts and then run “gradle packageMobile” without “clean” it doesn’t rebuild corresponding modules. I figured out this after building it on continuous integration server and sent an APK to QA witch was built differently from the one built on my machine.
Workarounds: 1) always “clean” (witch is obviously slow) 2) write custom scripts calculating md5 of the build scripts

This is the designed behavior. Tasks are UP-TO-DATE so long as the inputs and outputs don’t change. However, we have no way of knowing whether your changes to the build script might change the way the outputs are created (ex. I modify the implementation of a custom task). We certainly do not want any modification made to the build script to cause all tasks to be out of date. Generally, simple builds script changes do affect inputs (modifying dependencies, properties, adding/removing flavors, etc) which will cause the appropriate tasks to be executed again. Depending on the change you make you have to a) perform a clean before the next build or b) add/remove any related task inputs/outputs.

Thank you for the replay. Still cannot get your point. To my mind any changes of the build script change the output (otherwise they are senseless and should not be made). Any simple workaround? May be I can make gradle consider build.gradle file as input?

This is not strictly true. I could change logging levels, modify test/compile forking, repository credentials, task name/description, etc. None of which would modify the build output. More importantly, we have no way of knowing which output would be affected by any particular build script change, requiring every task to be rerun even for the most insignificant of build script changes (adding a comment). We by no means want that to be the default behavior, although it can be forced by using the --rerun-tasks command line argument.

As a workaround you might consider setting rerunTasks in an init script (perhaps that is used only in CI) based on modifications made to the build.gradle file. This would of course not take into consideration changes to script-plugins, buildSrc, etc. In practice, cleaning build output in response to build script changes is still an explicit operation. This could possibly change in the future as we move to the new configuration model.