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.

legrab legrab I'll fill this later Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help 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. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. 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 Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures.

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