# Gradle守护进程将在构建结束时停止，因为空闲时间已达3小时30分钟

- **ID:** `cicd/gradle-daemon-stopped-build`
- **领域:** cicd
- **类别:** system_error
- **错误码:** `GRADLE_DAEMON_IDLE_TIMEOUT`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

Gradle守护进程空闲时间过长将被终止，导致后续构建需重新启动守护进程并丢失缓存优势。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Gradle 7.6 | active | — | — |
| Gradle 8.0 | active | — | — |
| Gradle 8.5 | active | — | — |

## 解决方案

1. ```
   Set a reasonable idle timeout in gradle.properties: org.gradle.daemon.idletimeout=3600000 (1 hour) and ensure CI jobs complete within that window. Also use --build-cache to persist outputs.
   ```
2. ```
   Run 'gradle --stop' before starting a new build to force a fresh daemon, or configure CI to reuse the same daemon across steps by not exiting the JVM.
   ```

## 无效尝试

- **** — Simply increasing idle timeout may mask underlying memory issues or long-running CI jobs that should be optimized, and doesn't fix the root cause of long build times. (65% 失败率)
- **** — Disabling the daemon removes caching and warm JVM benefits, making builds significantly slower (up to 50% slower) in CI environments. (80% 失败率)
