Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom build rules for Eclipse

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?

like image 730
David Given Avatar asked Jan 19 '23 09:01

David Given


1 Answers

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.

like image 143
Sean Patrick Floyd Avatar answered Jan 30 '23 23:01

Sean Patrick Floyd