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

查看:17
本文介绍了如何阻止 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 代码在启动时被删除.如何声明 gradle Antlr 任务输出规范以避免不必要的重建.

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天全站免登陆