为什么要运行'gradle clean'? [英] Why run 'gradle clean'?

查看:1966
本文介绍了为什么要运行'gradle clean'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我要运行'gradle clean build'而不是'gradle build'?据我所知,gradle可以检测源变化并在需要时更新最终的工件。那么,为什么我仍然需要'干净'?

clean任务 java插件,它只是删除buildDir文件夹,从而清除包括以前版本中不再相关的剩余物在内的所有内容。不这样做可能会导致不清楚的构建,这可能会因为构建由以前的构建产生的构件而被破坏。

例如,假设您的构建包含多个失败的测试你认为这些已经过时,因此需要删除。如果没有清理测试结果(使用cleanTest任务)或完全构建(通过运行干净的任务),您将会遇到失败的测试结果,从而导致构建失败。类似的副作用也可能发生在从源代码中删除的资源/类中,但仍保留在未清理的构建文件夹中。


Why would I run 'gradle clean build' instead of 'gradle build'? From what I understand, gradle can detect source changes and update the final artifacts if needed. So why would I still need to 'clean' ?

解决方案

The clean task is defined by the java plugin and it simply removes the buildDir folder, thus cleaning everything including leftovers from previous builds which are no longer relevant. Not doing so may result in an unclean build which may be broken due to build artifacts produced by previous builds.

As an example assume that your build contains several tests that were failed and you decided that these are obsolete thus needs to be removed. Without cleaning the test results (using cleanTest task) or the build entirely (by running the clean task) you'll get stuck with the failed tests results which will cause your build to fail. Similar side effects can happen also with resources/classes removed from the sources but remained in the build folder that was not cleaned.

这篇关于为什么要运行'gradle clean'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆