Skip to content

Gradle build cache miss due to volatility of SpotlessTask.steps input #2168

@jprinet

Description

@jprinet

Summary

  • Gradle version: any
  • Spotless version: 7.0.0.BETA1
  • OS: any

Spotless configuration

See this example in the JUnit5 project

Expected behavior

Run the build twice without changing the code and get a Gradle build cache hit on spotlessJava task

Current behavior

A cache miss occurs in the second build scan

First Build Scan®
Second Build Scan®

Due to the SpotlessTask.steps value being different in the two builds:
Screenshot 2024-06-12 at 4 06 22 PM

Steps to reproduce

cd /tmp
git clone [email protected]:junit-team/junit5.git junit5-1 --depth 1
git clone [email protected]:junit-team/junit5.git junit5-2 --depth 1
cd junit5-1
gw clean :junit-platform-console:spotlessJava -Dgradle.user.home=../guh -Dgradle.cache.remote.enabled=false --scan
cd ../junit5-2
gw clean :junit-platform-console:spotlessJava -Dgradle.user.home=../guh -Dgradle.cache.remote.enabled=false --scan

Reasons

The SpotlessTask.steps is declared as task input but deserializing/serializing the collection is not consistent

Fix

Use a consistent representation of the input by using the steps name.
This assumes that the step name is unique.

See this Build Scan®️ illustrating the build cache hit with the fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions