问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/29802668/how-can-i-stop-netbeans-8-from-deleting-generated-code-at-startup