Geertjan's Blog

  • February 15, 2008

Maven is Magic in NetBeans IDE 6.0

Geertjan Wielenga
Product Manager
I came across Mark Ashworth's Connext-Graphs project a few days ago and then found that the project sources, including samples, are provided as Maven projects. Mark told me that I would first need to do a "mvn install" on the main project, after which I would be able to build the other project, i.e., the one that provides samples. So, being ignorant of Maven and all it entails, I thought: "Hmmm. I guess I'll go to the Synaptic Package Manager and see if I can find Maven there." I also googled around a bit.

Of course, I was aware of the fact that there's a NetBeans plugin for Maven. However, I assumed I'd need to install some command line tool first, which would then need to be registered in the IDE, after I'd installed the Maven plugin. At some point, I thought: "Maybe I'll install the Maven plugin first. Then I'll look for the place where I need to register the command line tool and go from there." So I went to the IDE's Plugin Manager, searched for Maven, and then had it installed 3 seconds later.

Next, I went to the New Project wizard. I thought: "Maybe I'll be able to import the Maven projects that I've downloaded from Mark's site. Once I've imported them, maybe I'll be able to build." Sure enough, I found a project type for importing Maven projects:

I clicked Next. Guess what I found? A message telling me: "Hey buddy, you don't need to import at all. Just open the project, NetBeans is smarter than you think!" Or, words to that effect:

So, I could simply open both projects, without doing anything special at all. I chose File | Open Project and then browsed to where I'd downloaded the projects from the dev.java.net site. I found that the IDE recognized the projects, because the typical NetBeans project icon showed for both of them and I thus was able to open them. Once opened in the IDE, they look like this:

And... there are contextual menu items for tasks such as building the projects:

In the end, I didn't need to do anything at all. I simply opened the projects, built them, and then ran the samples. It was an utterly boring experience, I had no issues to file in Issuezilla and I had no problems to solve at all, in any shape or form. Life sucks sometimes.

Join the discussion

Comments ( 6 )
  • Anuradha G Friday, February 15, 2008

    Hey Geertjan last January I joined to MevenIDE Project I working with Milos on MevenIDE 3.1 version there are more Magic on the way :)

  • huntch Friday, February 15, 2008

    We use Maven and the Maven plug-in for NetBeans at Project Grizzly (http://grizzly.dev.java.net). It works really well!

  • Markus Härnvi Saturday, February 16, 2008

    The Maven support is really nice. Much better than in Eclipse. I would like a more modern Maven version bundled. Or a simple way to upgrade it. You can use an external Maven installation, but then you lose some features. A lot of projects require 2.0.6 or newer.

    The support for building apps on NetBeans platform with Maven could be better, but Milos is doing a great job there.

  • henrik Saturday, February 16, 2008

    I use the maven plugin as well, it is very nice except for one issue...

    The netbeans profiler is does not work with maven projects...You can still connect to a running java app, but the usual project integration is gone.

    I hope this gets fixed soon

  • Geertjan Tuesday, February 19, 2008

    Thanks all for the comments/feedback. I'm looking forward to profiling support for Maven projects too, Henrik.

  • Carlos Gómez Wednesday, February 4, 2009

    Hi Geertjan:

    I'm developing an application based on tapestry5

    and I'm interesting in maven plugin in netbeans because Tapestry5 has the "live class reloading" feature so with it you can save the java file and then view the change witout redeploy the web application like eclipse does: http://bbwebcraft.blogspot.com/2009/01/task-3-rapid-turnaround-in-tapestry-5.html

    I posted the next question in netbeans forums but I haven't an answer:

    With netbeans you can "deploy on save" on web applications and "compile on save" on java applications BUT you can't "compile on save" on webapplications in order to implement live class reloading, so you know if with Netbeans7.0 and maven plugin you can do it ?

    Thanks in advance.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.