Custom build rules for Eclipse

北城余情 提交于 2019-12-31 01:47:08

问题


I have a Java project that uses some autogenerated source code. This source code is produced by a command-line tool --- Bison, actually --- from a special source file.

I would like a way to have the Java source automatically regenerated whenever necessary when I press the 'build' button in Eclipse. Is this possible, and if so, how?

Normally I'd integrate this into the project makefile, but of course this is Java, and it doesn't use makefiles. I've looked at ant, but ant seems rather hostile to traditional command-line tools. I know something like this is possible with the built-in Eclipse builder because the Android development kit does it; so what is it doing?


回答1:


Right-click the Project, select Properties > Builders > New ... > Program.

There you can select a command line tool that will be run whenever the project is built.


For completeness: this is an Eclipse-only solution. I would recommend you to use a build system instead of plain Eclipse. Both Maven and Ant integrate nicely with Eclipse (Maven through m2eclipse, Ant through the same Builder mechanism as above), possibly others as well.

With Maven, you would use exec:exec (usage).

With Ant you would use the <Exec> task.



来源:https://stackoverflow.com/questions/6469524/custom-build-rules-for-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!