Search code examples
javaeclipsecode-generationauto-generate

Eclipse: auto execute and generate code on save


I'm using Eclipse and I wanted to create a system that automatically generates java source code every time I save the project. More precisely I want to search for some files in a directory, generate static attributes for each of them and generate some methods every time the project is updated/saved. I thought that a piece of code that could be auto-executed by Eclipse would be fine, but I don't know if it's even possible. How can I achieve this behaviour?


Solution

  • You can specify a program or Ant script to be run when a project needs building in the 'Builders' section of the Properties for a Project.

    You can also write an Eclipse plugin 'Incremental Builder' using the 'org.eclipse.core.resources.builders' extension point. More information about this in the Eclipse help.