views:

118

answers:

3

I've set an external tool (sablecc) in eclipse (3.4) that generates a bunch of classes in the current project. I need to run this tool and regenerate these classes fairly frequently. This means that every time I want to run sablecc, I have to manually delete the packages/classes that sablecc creates in order to ensure that I don't have conflicts between the old and new generated classes. Is there some easy way to automate this from within eclipse or otherwise?

A: 

You can tell Eclipse to refresh the workspace (or parts of it) after an external tool has been run. This should force Eclipse to detect any new/deleted classes.

JesperE
No, that won't quite do what I want. Sablecc ignores anything already in the project and generates its classes on top of what is there. I need to delete the old generated classes before calling sablecc.
Paul Wicks
A: 

JesperE is referring to the option "Refresh->Refresh resources on completion" in your external tools configuration for running sablecc.

flicken
+1  A: 

Not sure if I understand your point right, I suppose you need to delete old classes before running sablecc because some of them would not be eventually created in new run.

It is probably best to write short Ant build.xml with the target, which first removes the classes (Ant delete task) and then runs sablecc (Ant exec task). It is also possible to preset eclipse so that it refreshes workspace after Ant finishes.

Put the build.xml anywhere to project, right click, Run As/Ant Build.

Just for the sake of the clean style, you could then call sablecc with its Ant task (implemented by org.sablecc.ant.taskdef), instead of running it externally in new process.

David Skyba