One of the nice things about Rails is how it can automatically spit out common code for you. For example, if you need a new Model or Controller, Rails can spit one out for you, ready to be customized, with one line of code.
I've thought for a while that similar capabilities could be obtained using Apache ANT, which comes built in to Eclipse or can be downloaded separately and run from the command prompt. Last night I had a few minutes so I decided to try it for fun. And it seems to work pretty well!
For example, in a Model-Glue app, I could execute an ANT task called create_controller.xml. What this would do is prompt me for the name of the controller. Say I enter "StoreController". Then it copies the Controller from the Model-Glue application template folder into my application's controller folder and names it StoreController.cfc. Then it embeds new XML into the Model-Glue config XML file like:
<controller name="StoreController" type="deli.controller.Controller"> <message-listener message="OnRequestStart" function="OnRequestStart" /> <message-listener message="OnQueueComplete" function="OnQueueComplete" /> <message-listener message="OnRequestEnd" function="OnRequestEnd" /> </controller>
into the controllers block. It does this by doing some replace commands on the Model-Glue XML, as well as replacing the controller name and the application name. It does the same sort of replace within the CFC to embed the proper name and path.
I also did this with a create_event.xml file. This prompts me for the name of the event, and a view file name, and then creates the XML for the event, copies a view template into my views folder, and name it to match the view file name I specified.
If you've used the Model-Glue application template to create a new application, you know it already does some copying of files and some replacing. It wouldn't be hard to imagine it also copying and creating a set of build XML files to perform common tasks like this. These build XML files would all be set up specific to the newly generated app, with the proper paths and application name already embedded within them. And obviously the same sort of thing could be done with any framework (ColdBox, Fusebox, Mach-II, etc.)
These two examples were quite simple to create. And while they don't save a huge amount of time, it does save some time. I don't have to worry about creating new view or controller stub files, or creating the base XML in the config file. The build XML will do this for me in about one second. I could imagine making these do much more complex things if necessary, since ANT has a very large set of tasks that it can perform, including RegEx processing and replacement.
I was curious to see if anyone had thought about something like this before, and if this sounds like it would be useful.