Tuesday, February 12, 2008

NetBeans 6.0 Maven Integration

As a proponent of continuous integration, I naturally don't endorse one IDE over another. The choice should be free and open for developers to choice what works best for them. The important thing is that the project should not be reliant on an IDE to build. That is, there must be an independent build tool that can function outside of any IDE, whether it be ant or maven or whatever.

I have used several IDEs over the last couple of year to include Eclipse, IDEA and NetBeans . They all have their strengths and weakness and for the projects I have been working on, I ended up switching around quite a bit. With the recent announcement of the new Netbeans 6.0, I wanted to revisit it's capabilities and see what was new, particularly with its maven integration.

While the Netbeans installer was downloading, I started to search for what plugins I would need to do maven->Netbeans or Netbeans ->maven project conversions. Most of what I found looked outdated and didn't look easy to use. With a little stumbling around I found out that the Mevenide project does now support Netbeans 6.0 (this is not apparent on their Netbeans project page). So I installed the Mevenide Maven2 plugin.

And was blown away!

There is no conversion of project types from maven->NetBeans . It just works natively. File > Open Project and browse for your existing maven project. Bingo.

I actually started by opening a parent project, <packaging>pom</packaging>, thinking that the Mavenide wouldn't know what to do with a multi module project, but it just worked, too! It showed me the project files, libraries, test libraries and the modules that this parent included. Too cool.



So then I double clicked my war module name hoping for the best and was not disappointed. It opened the war project in the project pane and I was off and running.



Right click on the project name to run the more common maven goals from right inside NetBeans. To run custom goals, you can create a Custom > Goals... goal that you can use to chain together whatever goals you want for a maven execution. This is the only thing I did that actually created a custom file on my filesystem. Everything else was native.

How's that for a slice of fried gold?
So, here's a big high five to to the Mevenide team on a job well done! (And update your NetBeans project page to highlight that it works in Netbeans 6.0. This is important news to advertise!).

9 comments:

Milos said...

Hey,

thanks for the positive review.

The http://mevenide.codehaus.org/m2-site/ page makes reference to NetBeans 6.0 compatibility. What was your entry point page to the website that made it unclear? There's a bit of confusion with the layout as we have old legacy maven1 integrations at the root of the website, but still the maven 2 integration should be easy to find.

Jeff Black said...

Hello milos,

I referring to this page. This page gave me the initial impression that there was not yet a NB6.0 compatible Mevenide plugin. I think this would be a good place to highlight that it works with NB6.0.

Milos said...

That page belongs to the old maven1 support. The page mentions the maven2 support at the end. I'll try to come up with something that will make it more obvious that the page is for m1 and where m2 support is.

Most users should be getting the Maven support straight from the default NetBeans update center nowadays through the Options/Plugins dialog. In some future version it could even become part of the default installation.

DJ said...

can you debug java programs in a Netbeans Maven Project ?

Then it is useful.

svetzal said...

You sure can debug in Netbeans for a Maven project, and profile too. It just works as expected.

I haven't put much time into figuring out if I can do hot-deployment of EAR or WAR projects to a container though, anyone got this working?

Still jealous of native project types for convenience like this...

Anonymous said...

Are there any conversion tools that will allow my maven built JFrames and JPanels to utilize netbeans's GUI builder ?

afisk said...

I don't understand why Eclipse/NetBeans wouldn't just support opening Maven projects themselves. Is that really so hard? Seems like such an obvious feature.

Jeff Black said...

afisk> A well done plugin is just as good in my book. In this case, the maven plugin has improved dramatically in the last few months to the point where the integration is seamless from my point of view. Open, build, and test the project. I am pretty sure the plugin is visible in the normal plugin update centers now, so just filter the available plugins by 'maven' and install.

Jeff Black said...

svetzal> I haven't tried hotdeploying from netbeans directly, although if in your maven project you do the minimal cargo plugin setup for say tomcat, jetty or glassfish, you can configure the custom cargo:deploy | undeploy | redeploy maven goals in netbeans.