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.

Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Nam Tran Nam Tran 10 years as fullstack developer ISHANTDEEP SINGH ISHANTDEEP SINGH Senior Software Engineer with 7+ years of experience in React, JavaScript, TypeScript, Next.js, and Node.js. I’ve also worked as a tech lead for startups, owning end-to-end technical execution including architecture, development, scaling, and delivery. I bring a strong mix of hands-on coding, product thinking, and technical leadership, and I’m comfortable building products from scratch as well as improving and scaling existing systems. 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 Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Caio Rodrigues Caio Rodrigues I'm a full-stack developer focused on building practical and scalable web applications. My main experience is with **React, TypeScript, and modern frontend architectures**, where I prioritize clean code, component reusability, and maintainable project structures. I have strong experience working with **dynamic forms, state management (Redux / React Hook Form), and complex data-driven interfaces**. I enjoy solving real-world problems by turning ideas into reliable software that companies can actually use in their daily operations. Beyond coding, I care about **software quality and architecture**, following best practices for componentization, code organization, and performance optimization. I'm also comfortable working across the stack when needed, integrating APIs, handling business logic, and helping transform prototypes into production-ready systems. My goal is always to deliver solutions that are **simple, efficient, and genuinely useful for the people using them.** 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. 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. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. legrab legrab I'll fill this later

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