Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's the difference between gradle clean build and clean build?


Asked by Ariana Huffman on Nov 30, 2021 Gradle



Personally, I'd consider such behaviour a bug in the build logic, but you might have a different opinion. By extension, gradle clean build and gradle build clean should do the same thing, namely a clean build. The assumption here is that a clean task in project1 does not affect project2 production tasks, but that seems reasonable enough.
And,
./gradlew clean Uses your project's gradle wrapper to execute your project's clean task. Usually, this just means the deletion of the build directory.
In addition, Gradle is 2-3x faster for clean builds, about 7x faster for incremental changes, and up to 14x faster when Gradle task outputs are cached. This GIF shows the clean build scenario side-by-side so you can get a feel for the difference (without build cache).
Moreover,
The build scripts of all projects which are part of the build are executed. Gradle determines the subset of the tasks, created and configured during the configuration phase, to be executed. The subset is determined by the task name arguments passed to the gradle command and the current directory. Gradle then executes each of the selected tasks.
Keeping this in consideration,
Is essentially the same as #2. The colon represents the task path. Task paths are essential in gradle multi-project's, not so much in this context. It means run the root project's assembleDebug task. Here, the root project is the only project. Is essentially the same as ./gradlew clean.