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)
BUILD FAILED: Resource not found (cached incorrectly)ClassNotFoundException: previously compiled class not foundStale 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.

AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. Basel Issmail Basel Issmail ’m a Senior Full-Stack Developer and Tech Lead with experience designing and building scalable web platforms. I work across the full development lifecycle, from translating business requirements into technical architecture to delivering reliable production systems. My work focuses on modern web technologies, including TypeScript, Angular, Node.js, and cloud-based architectures. I enjoy solving complex technical problems and helping teams turn product ideas and prototypes into working platforms that can grow and scale. In addition to development, I often collaborate closely with product managers, business analysts, designers, and QA teams to ensure that solutions align with both technical and business goals. I enjoy working with startups and product teams where I can contribute both as a hands-on engineer and as a technical partner in designing and delivering impactful software. Victor Denisov Victor Denisov Developer legrab legrab I'll fill this later Meïr Ankri Meïr Ankri Full-stack developer specializing in React / Next.js / Node.js with 6+ years of experience. I've worked across various sectors including automotive (Reezocar/Société Générale), healthcare (Medical Link SaaS), and e-commerce (Glasman). I build web apps end-to-end, from architecture to production, with a focus on scalability, performance, and code quality. I also mentor junior developers and contribute to technical decisions and code reviews. Nam Tran Nam Tran 10 years as fullstack developer Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. 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 Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever

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