user401142
user401142

Reputation:

Run a script in eclipse before build

Simply put:

In eclipse how do I run a shell/batch script when I build? I have an external tool that can be run by hand but I want to trigger it when the project is built. Using build variables in the script would be an added bonus.

Why I want this:

I work on multi-platform games for mobile. The teams in the company I'm at use X-Code, Visual Studio, and Eclipse (Momentics) for our games. We want to be able to pick up a phone and see overlay on-top of it with information such as who built it, when it was built, what branch and revision it's from, and what library versions are being used. I've done this with X-Code by running a script on build that dumps some of that information to the resource directory of my game that I can then parse at runtime. It's really simple and I'm up for alternate suggestions if you have them; keeping in mind it must work for the three IDE's our developers use.

Bonus Sugar:

In X-Code we can use build variables which would be super nice to have for eclipse as well. I use them to change to the active cocos2d-x repository and get a git log to tell us when the last commit to that repository was made and by who. If that isn't possible in eclipse I can figure something out.

Thanks in advance!

Upvotes: 13

Views: 13255

Answers (1)

Zoltán Ujhelyi
Zoltán Ujhelyi

Reputation: 13858

Add a custom builder to your project: open Project properties from the popup menu, on the builders page add a new Program. That will open a "External tool configuration" page.

There you can define a script to run, and also add parameters, where you can add Eclipse variables, such as ${workspace}, etc.

Be careful though: this will run every time when the incremental project builder runs, and the configuration is shared through version control (so beware of absolute paths).

Upvotes: 13

Related Questions