Full rebuild triggered for single file change in github action

Hi All,

I have enabled gradle cache in github action workflow with setup-gradle action, also enabled org.gradle.caching=true in gradle.properties, from the github action log I can see the gradle cache works:

Cache restored successfully
[38](…/actions/runs/112251/job/10441433#step:6:39) Restored Gradle User Home from cache key: v9-gradle|Linux|buildFlight[2cfb035f8a6a515bf8d9419affa74967]-da091ed95fd724e8131babc535861d85e87a293c 

But single java file change always triggers Full recompilation:

> Task :flight-engine:compileJava
Build cache key for task ':flight-engine:compileJava' is 544a825bea0513c5bcebc5ed77d946c0
Task ':flight-engine:compileJava' is not up-to-date because:
  No history is available.
The input changes require a full rebuild for incremental task ':flight-engine:compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.

While Incremental compilation is triggered in local:

> Task :flight-engine:compileJava
Build cache key for task ':flight-engine:compileJava' is a185592957635143bfdcb9768ab59679
Task ':flight-engine:compileJava' is not up-to-date because:
  Input property 'stableSources' file /xxxx/AbreuEngine.java has changed.
Created classpath snapshot for incremental compilation in 0.029 secs.
Compiling with JDK Java compiler API.
Incremental compilation of 2 classes completed in 1.485 secs.

could you help on this issue, is there anything I missed in gradle command or github action workflow?

here is the gralde cache in github action:

    - name: Setup Gradle
      uses: gradle/actions/setup-gradle@v3

this gralde build to compile:

./gradlew  --parallel  --build-cache

That has nothing to do with the build cache.
It stores the full output of a cacheable task if all inputs are the same.
The information about incremental compilation has nothing to do with the build cache.
So yes, if the inputs are the same, a build cache entry can be reused, if any input changes, the task has to rerun.

Got it, thanks. So is there anyway we can enable Gradle incremental compilation in github action workflow?

Imho you shouldn’t, but I guess if you determine which files are used for that and configure them to be cached, it might work.