Claude Code deployment

Gradle Build Cache Causes Stale Artifacts

Gradle build cache contains stale artifacts from previous builds. Changes to source files aren't reflected in the compiled output, causing deploying of old code. Incremental builds work correctly, but CI/CD pipeline with partial cache hits behaves unexpectedly.

This is particularly problematic when generated code or resource files are cached but source changed.

Error Messages You Might See

BUILD FAILED: Resource not found (cached incorrectly) ClassNotFoundException: previously compiled class not found Stale artifact deployed (code changed but not rebuilt)

Common Causes

  1. Build cache not invalidated when dependency versions change
  2. Task outputs cached incorrectly without accounting for input file changes
  3. Resource files or generated code cached with wrong invalidation rules
  4. Gradle daemon holding stale classpath in memory
  5. CI/CD pipeline using shared cache across builds with different configurations

How to Fix It

Disable cache for CI/CD: ./gradlew clean build --no-build-cache. Or invalidate selectively: ./gradlew cleanBuild. Add @CacheableTask annotations carefully with correct inputs/outputs. Kill Gradle daemon: ./gradlew --stop. In CI, prefer clean builds over cached builds for reliability.

Real developers can help you.

Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. Omar Faruk Omar Faruk As a Product Engineer at Klasio, I contributed to end-to-end product development, focusing on scalability, performance, and user experience. My work spanned building and refining core features, developing dynamic website templates, integrating secure and reliable payment gateways, and optimizing the overall system architecture. I played a key role in creating a scalable and maintainable platform to support educators and learners globally. I'm enthusiastic about embracing new challenges and making meaningful contributions. Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Matt Butler Matt Butler Software Engineer @ AWS Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Nam Tran Nam Tran 10 years as fullstack developer Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Should build cache be used in CI?

Use with caution. For reliability, prefer: ./gradlew clean build in CI. Cache is useful locally for fast iteration.

How to completely clear the build cache?

Run: ./gradlew clean && rm -rf .gradle/build-cache/. Then rebuild: ./gradlew build

Why does CI cache behave differently than local?

Local cache persists across builds and daemon is reused. CI typically starts fresh. Use --no-build-cache in CI if experiencing issues.

Related Claude Code Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help