求助:Eclipse放弃增量构建频繁触发全量清理重建问题
Eclipse JDT 增量构建失效与无限循环问题
环境信息
- Eclipse版本:2024-03 Java开发者版(旧版本也存在相同问题)
- 已启用设置:
- Windows -> 首选项 -> 运行/调试 -> 启动 -> 启动前(如有需要)执行构建
- 项目 -> 自动构建
- 未使用Buildship(Gradle)或m2e(Maven)等集成构建工具
问题现象
- 对文件做微小修改即触发全量清理重建,无法正常使用增量构建
- 启动单元测试或主程序时,即便无任何代码修改也会触发全量清理重建;更严重的是,程序运行后后台会再次触发全量重建,导致随机类抛出
NoClassDefFoundError - 构建过程陷入清理-重建的无限循环
项目配置
.project文件
<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>some-project</name> <comment/> <projects/> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> </natures> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments/> </buildCommand> </buildSpec> <linkedResources/> </projectDescription>
.classpath文件
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry including="**/*" kind="src" path="src/main/java"/> <classpathentry including="**/*" kind="src" path="src/main/resources/etc"/> <classpathentry excluding="etc/**" including="**/*" kind="src" path="src/main/resources"/> <classpathentry kind="src" output="build/classes/test" path="src/test/java"> <attributes> <attribute name="test" value="true"/> </attributes> </classpathentry> <classpathentry kind="src" output="build/classes/test" path="src/test/resources"> <attributes> <attribute name="test" value="true"/> </attributes> </classpathentry> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="lib" path="/path/to/some-library.jar" sourcepath="/path/to/some-library-sources.jar"> <attributes> <attribute name="org.eclipse.jst.component.dependency" value="../"/> </attributes> </classpathentry> <!-- skipped other lib entries similar to this one --> <classpathentry exported="true" kind="lib" path="C:/root/client/resources"> <attributes> <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> <classpathentry kind="output" path="build/classes/main"/> </classpath>
项目结构关联问题
项目目录结构如下:
root +---extensions +---projects +---some-project
- 仅
some-project为Java项目,其余均为常规项目 - 将
root项目从工作区移除后问题消失,重新添加则问题重现;即便工作区仅保留root(常规项目)和some-project(Java项目),问题仍存在 - 为
root添加资源过滤器排除some-project、关闭root项目均无效,只有移除root能彻底解决问题 - 临时解决方案:将
.classpath文件中的C:/root/client/resources替换为/root/client/resources(该写法要求root项目存在于工作区),修改后Java源码变更不会触发全量清理重建,但该场景无法在示例项目中复现
相关Bug说明
已有公开Bug报告记录了类似问题,核心场景为:当工作区中存在包含Java项目的父级常规项目时,JDT构建器会错误地触发全量清理与重建循环。
内容的提问来源于stack exchange,提问作者Nicolas Baumann
相关产品推荐
相关产品推荐

