Currently gradle considers absolute paths when resolving incremental build state. The result of this is that a workspace can’t be copied to a new location and have an incremental build work the same as in the prior workspace location.
This creates issue with regard to setting up build pipelines in a CI server where you’d like to clone a workspace from a prior build (or copy build artifacts from a prior build workspace into the new build workspace) and NOT have targets rebuilt (something of a cornerstone principle when it comes to constructing build pipelines).
Regardless of the build pipeline / CI issues, however, this just seems like a design flaw… workspace locations should be decoupled from what gradle is doing within that workspace.
In the example below, I would suggest that the “gradle build” in the “test2” workspace (copied from a just completed build in the “test” workspace) should show all tasks as being UP-TO-DATE.
$ mkdir test; cd test
$ gradle init --type java-library
:wrapper
:init
BUILD SUCCESSFUL
Total time: 4.338 secs
$ gradle build
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
BUILD SUCCESSFUL
Total time: 10.106 secs
$ gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
BUILD SUCCESSFUL
Total time: 5.342 secs
$ cd ..
$ cp -r test test2
$ cd test2
$ gradle build
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
BUILD SUCCESSFUL
Total time: 8.812 secs