如何在启动时阻止NetBeans 8删除生成的代码? [英] How can I stop NetBeans 8 from deleting generated code at startup?

查看:61
本文介绍了如何在启动时阻止NetBeans 8删除生成的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在NetBeans项目中有Antlr生成的Java代码.每次启动NetBeans时,它都会删除生成的代码,并迫使我在运行该项目之前对其进行重建.如果除了启动NetBeans外我什么也不做,则在项目完成加载后将其关闭后,就会发生这种情况.如何告诉NetBeans在启动时不要删除生成的代码?显然,当Antlr文件发生变化时,我仍然需要它重新生成Java代码.

I have java code generated by Antlr in my NetBeans project. Every time I start NetBeans, it deletes the generated code and forces me to rebuild the project before it can be run. This happens if I do nothing except start NetBeans and then close it after the project finishes loading. How can I tell NetBeans not to delete the generated code at startup? Obviously, I still need to have it regenerate the java code when the Antlr files change that generated it in the first place.

推荐答案

我发现有害行为与NetBeans配置无关.问题是我在build.gradle中声明"cleanAntlr"任务的方式中的一个错误.当NetBeans IDE首次加载gradle项目时,该任务在gradle的初始化和/或配置阶段未正确执行,导致生成的Java代码在启动时被删除.有关具体修复的详细信息,请参见

I discovered that the unwanted behavior has nothing to do with the NetBeans configuration. The problem was a bug in the way I had declared the "cleanAntlr" task in build.gradle. 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. The specific fix is explained in detail at How do I declare gradle Antlr task output specs to avoid unnecessary rebuilds.

这篇关于如何在启动时阻止NetBeans 8删除生成的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆