5gon12eder
5gon12eder

Reputation: 25459

Eclipse Code Generation Hook

I have a Java project in Eclipse. Some Java source code files are generated from an XML file with an XSLT style sheet. Currently, I'm manually rebuilding these files with rules defined in an external makefile when I realize the XML file has changed. It would be nice to have Eclipse know that it has to regenerate the files on build and delete them on clean. Is it possible to register some kind of hook for this?

Upvotes: 0

Views: 88

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20812

The easiest way is to write an Ant build file with clean and build targets. And then, add a builder to the project. (Project > Properties > Builders > New > Ant Builder.) On the targets tab, set the targets you want run under the various build triggers. On the refresh tab, set the resources to refresh so the workspace detects the changes that your Ant file will make.

Since you are doing an XSL transform, the built-in Ant xslt task helps because it can check if the output is up-to-date with the input and skip the transform if it is not needed. And, of course, for the clean target, you can use the delete task.

Ant comes with Eclipse and Eclipse adds a few more tasks and properties that you might eventually find useful.

If you did want to stick with your make file, you could add an External Program builder instead and use the build_type variable as an argument.

Upvotes: 2

Related Questions