buildSrc build is not cleared after build

We are using gradle 2.1 and deleting files in buildSrc can cause subsequent build to fail.

The scenario is: 1. Add groovy and groovy test to buildSrc 2. run assemble (we are using android) 3. Delete the test files 4. run assemble again. 5. Notice buildSrc:test will still be run again even though there is no test anymore.

The workaround is to manually remove buildSrc/build folder

This should only ever happen if all test files are deleted. It’s a known limitation of compile tasks that’s not specific to ‘buildSrc’, except that it’s harder to clean ‘buildSrc’ (as ‘gradle clean’ won’t help).

I think there should be a task created to clean buildSrc. e.g. .gradlew cleanBuildSrc that deletes the buildSrc/build folder and cleanAll will run clean and cleanBuildSrc.