为什么要运行“渐进式构建"而不是“渐进式构建"? [英] Why run 'gradle clean build' instead of 'gradle build'?

查看:84
本文介绍了为什么要运行“渐进式构建"而不是“渐进式构建"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我要运行gradle clean build而不是gradle build?

Why would I run gradle clean build instead of gradle build?

据我了解,Gradle可以检测源更改并在需要时更新最终工件.那为什么我仍然需要clean?

From what I understand, Gradle can detect source changes and update the final artifacts if needed. So why would I still need to clean?

推荐答案

清理任务 java插件定义,它只是删除了buildDir文件夹,从而清除了所有内容,包括以前的版本不再相关.否则可能会导致构建不整洁,并可能由于先前构建产生的构建工件而被破坏.

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.

作为示例,假设您的构建中包含多个失败的测试,并且您确定这些测试已过时,因此需要将其删除.如果不清除测试结果(使用cleanTest任务)或不完全构建(通过运行clean任务),您将陷于失败的测试结果中,这将导致构建失败.从资源中删除资源/类但保留在未清除的build文件夹中,也会发生类似的副作用.

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.

这篇关于为什么要运行“渐进式构建"而不是“渐进式构建"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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