My blog has moved!

You should automatically be redirected in 6 seconds. If not, visit
http://blogs.i2m.dk/allan
and update your bookmarks.

Wednesday, 6 August 2008

Project-based formatting in NetBeans 6.5

Being part of the NetBeans Community Acceptance Testing (NetCAT) Programme has definate advantages. For one, you get to try out all the new features planned and influence how they will work before being released to the general public (that is not quite true....anyone can download the daily development builds).



One of the features in the upcoming NetBeans 6.5 that I'm particularly happy about is Formatting by project. In NetBeans it has always been one configuration for all projects. This is slowly changing. During NetCAT for 6.1 the "Shared Library" feature was implemented to detach library management from NetBeans and thereby making projects more portable. So, this time the brilliant guys on the NetBeans development team implemented a feature making it possible to do project-based formatting. This is a great feature when you work on many different projects with different formatting requirements. Way to go! My hope is that for the next version of NetBeans they will also have made template management project-based.

10 comments:

mkleint said...

hey, seeing that you use Maven based project (as per screenshot), there's one additional feature that's particularly handy.
By default netbeans will write the formatting configuration to the basedir/nbconfigurations.xml file, however it's capable of reading the values from the pom.xml properties as well. So once you are happy with the formatting you've setup, copy the properties to your project's (or company's) parent pom.xml file into the properties section. All existing or newly created projects will inherit these values (unless they override them).

So the IDE configuration overhead get a bit smaller again..

Anonymous said...

Wow, this is really a great feature. I have my own ideas about code formatting, but I also work on projects with legacy code and don't want reformatting to make gratuitous changes and interfere with diffs.

So now I guess I can just set a formatting profile for those projects and get the best of both worlds.

Anonymous said...

Now it would be really perfect if the formatter could be used outside of netbeans. Eclipse can do it!

Allan Lykke Christensen said...

Milos: Thanks for the tip! That is really cool - it even works for POM (multi-project) projects, yippie! Do you by any chance know if it possible to specify the license property (project.license) as well?

mkleint said...

Allen: Yes, specifying license is possible for some time already, check http://mevenide.codehaus.org/m2-site/mevenide2-netbeans/customizations.html for details. It's not perfect (as it won't pick up the license from the license element of the pom, but it can be specified with a property in POM.

Allan Lykke Christensen said...

Fantastic!! I really think that kind of documentation needs to go into NetBeans.

Thanks alot

Anonymous said...

Allan,

Been popping into your blog once in a while - makes interesting reading - particularly the travel to Zambia.

Curious about your travels - are you self-employed, or part of a bigger company? I'm even more curious about how Zambia (business-trip you wrote about?) affords to pay consultants from Denmark - can't be cheap, and I'm sure the exchange rate doesn't help either.
Paul - Illinois USA

Anonymous said...

Oops - forgot to say : big fan of Netbeans. Use Eclipse also - both have good points. Wouldn't I love to have the best of both worlds in one IDE?
Paul

Allan Lykke Christensen said...

Hi Paul, thanks for following my blog. I use to be self-employed a couple of years ago, but two years back I decided to take up a permanent position in a Danish consulting company that focuses on development aid. I'm in the ICT division of the company and therefore get to be part of must of the IT projects we have world-wide (hence the frequent travelling). Our customers are not in the private sector but rather the large donor organisations such as the European Union, United Nations, World Bank, etc. This is of course the reason why there is a budget for consultants like myself.

Dessie said...

Importing & Exporting the NetBeans formatting to XML would be useful.

Also importing Eclipse formatting XML would be Great.