How gradle doing up-to-date check?

Hello, I am using gitlab-runner with gradle running in docker executor in my project.

Usually the pipeline have three stages: build, test, qa.

I ran these task in different stage:
build: gradlew assemble
test: gradlew check
qa: gradlew sonarqube

I think, once runner executing check task in test stage, it would use the bin file from build stage(means compileJava task should be marked as UP-TO-DATE).

Actually, it will run compileJava again in test stage, and both of them in qa stage.
I’ve read about Up-to-date checks in docs, tried pass artifacts between stages, or even touch file with the same ‘-t’ parmas before and after each job.

But it doesn’t work, gradle still execute compileJava task at each stage, thinking the bin data is not usable.

Is there anything I missed to keep between stages that let gradle think the bin file is out-of-date?

My gradle version is 3.2.1

Thank you!

Sorry, it’s my mistake, I forgot passing my .gradle directory to the following stage.