I would like to run a custom shell script upon clicking Build Project
in Eclipse. I tried modifying the "compile" section in build.xml, but my script is not getting run. Invoking ant debug
on the commandline works, however.

- 22,306
- 30
- 110
- 141
3 Answers
You needn't involve ant unless you already want to.
Somewhere in the menus there is a thing for builders. Just add another one and customize it. This gives your typical IDE run-external-command type capability with assorted variables for project path, name, etc that you can use in constructing the command line.
Note: while this answer was intended to state the general approach rather then specifics, user149408 suggests that at least in some Eclipse versions, this would be achieved by navigating menus to Project > Properties and choosing Builders.

- 39,853
- 6
- 84
- 117
you can right click the build.xml file and choose run as ant script, which will run the default target or get the second option which lets you choose a certain target to be run.

- 627
- 1
- 5
- 14
-
1So the default eclipse "Build Project" does not go through ant? – zer0stimulus Oct 07 '10 at 14:55
-
1the build project uses the eclipse compiler and is used for development purposes. if you want to compile using ant and deploy your application somewhere, right click the ant build file. – virgium03 Oct 07 '10 at 15:17
Build.xml should be active document. So open Build.xml in Eclipse and click debug. Eclipse will run ant with your custom build file instead of standard build. You will see build output in console.

- 2,905
- 1
- 23
- 20