简体   繁体   English

如何阻止NetBeans 8在启动时删除生成的代码?

[英]How can I stop NetBeans 8 from deleting generated code at startup?

I have java code generated by Antlr in my NetBeans project. 我在NetBeans项目中有Antlr生成的Java代码。 Every time I start NetBeans, it deletes the generated code and forces me to rebuild the project before it can be run. 每次启动NetBeans时,它都会删除生成的代码,并迫使我在运行该项目之前对其进行重建。 This happens if I do nothing except start NetBeans and then close it after the project finishes loading. 如果除了启动NetBeans外我什么也不做,则在项目完成加载后将其关闭,就会发生这种情况。 How can I tell NetBeans not to delete the generated code at startup? 如何告诉NetBeans在启动时不要删除生成的代码? Obviously, I still need to have it regenerate the java code when the Antlr files change that generated it in the first place. 显然,当Antlr文件发生变化时,我仍然需要重新生成Java代码。

I discovered that the unwanted behavior has nothing to do with the NetBeans configuration. 我发现有害行为与NetBeans配置无关。 The problem was a bug in the way I had declared the "cleanAntlr" task in build.gradle. 问题是我在build.gradle中声明“ cleanAntlr”任务的方式中的一个错误。 The task was incorrectly being executed during the initialization and/or configration phases of gradle when the NetBeans IDE first loaded the gradle project, which resulted in the generated java code being deleted at startup. 当NetBeans IDE首次加载gradle项目时,该任务在gradle的初始化和/或配置阶段未正确执行,导致生成的Java代码在启动时被删除。 The specific fix is explained in detail at How do I declare gradle Antlr task output specs to avoid unnecessary rebuilds . 如何声明gradle Antlr任务输出规范以避免不必要的重建中详细说明了特定的修复程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM