Friday, June 26, 2009

NetBeans and Frameworks

NetBeans seamlessly provides an integration with the most common frameworks, e.g. GWT, jMaki, Spring Web MVC, JSF, Struts, Hibernate.

When we create a new project we are asked whether we want to use any of these frameworks in our application. Should we need to add them later it is very easy to do so: from the project properties you select the Frameworks category, click the Add... button, select the framework(s) you need and you're done, as NetBeans takes care of (almost) everything, e.g. if you add the Hibernate framework NetBeans will add the necessary libraries and references and create a hibernate.cfg.xml file.

What I never managed to realize is how you get rid of a framework, as there are no Remove buttons whatsoever. That's where a versioning system comes useful (disclaimer: this is definitely NOT the only reason for which you should use one). If you have your whole project under versioning (including NetBeans administrative files) as we do, after committing everything on the repository you can simply add your framework and ask your versioning system to show you the changes and use a simple diff on each modified or added file and save the differences for future reference: in this way you can pretend you know the NetBeans internals like the back of your hands, while you just used a sleight of hand.

If you want to remove the framework now you can just revert all modifications and delete added files, but if you want to remove it after some other coding you can always go back to your reference files.

I'm sure there's a way to automate all this at least a little bit, but for now I'll be content with this.

No comments: