Maven Demo (5 Minutes)


Thanks to Milos Kleint for providing the bulk of this demo script. The difficulty was actually finding a Maven 2.0 project, so for this purpose, we're going to use one of the Maven projects itself, the Maven Repository Manager (Archiva).

Product Versions Supported

NetBeans 5.0+

NetBeans 6.0 M6+ has newer version of Maven support on the Dev Update Center

Points to Hit

  • Open existing Maven projects without any imports or synchronizations. The NetBeans integration works directly and solely on top of the Maven project files.
  • Create new Maven projects

Demo Prep

  • Download and install the latest version of the Maven plug-in for NetBeans. If using 6.0 M6+, please use the Maven Plugin from the Development Update Center instead.
  • We need a project that uses Maven for it builds. For this, we'll use the Maven source itself. You have 2 options to get it:
  • Open and build the Archiva project.


  • Maven will download dependencies. If you're behind a proxy, configure it in your settings.xml, found in the .m2 directory of your user directory. For example, my settings.xml is at C:\Documents and Settings\Brian\.m2. Create the file if it doesn't already exist. Here's an example:
  • You're working with the trunk of the Archiva project. If it fails to build, update and try again :-).
  • If the build fails because of failing tests in the Maven Repository Artifact Discovery project, just delete those tests :-).
  • If the build fails for other reasons, skip that part of the demo :-).


Opening the Project

  • Browse to the Archiva directory and notice that NetBeans recognizes the Maven project. There's no need to import! Open the Maven Repository Manager (MRM) project, which is the archiva directory itself.
  • All of the MRM's sub-projects are also opened.

Viewing the Project

  • Right-click the project and show the goals under Run lifecycle phase (these are analogous to Ant tasks).
  • Expand the main project (Maven Repository Manager)
  • Project Site - files Maven uses to generate project documentation
  • Dependencies, Test Dependencies & Runtime Dependencies - discussed in a moment.
  • Modules - These correspond to the sub-projects that were opened along with the main project.
  • Right-click the Modules node and select Show Module Graph.
  • Project Files - Show the POM file.
  • Expand the Maven Repository Manager Web Application.
  • Sources & Test Sources - Java source files
  • WebApp Sources - Sources related to the web application (jsps, css, config, etc.)
  • Other Roots & Other Test Roots - miscelaneous stuff, like bundle files, config files that go into the jar.

POM Editing

The POM (Project Object Model), pom.xml, defines the project.

  • Open the project POM file in the editor
  • Show code completion for the elements by pressing Ctrl+Space after the opening caret (<).
  • Show code completion for elements such as <module>
  • Hyperlinking - Hold down the Ctrl key and mouse over a module name to jump to that module's POM. All URLs are also linkable in this manner.

Dependency Management

  • Expand the Dependencies node of the Maven Repository Manager Configuraion project (this project has a managable number of dependencies).
  • Right-click the Dependencies node
  • Download Dependencies - will fetch dependencies that are not already in the local repository.
  • Check repositor(ies) for javadoc and sources - will greatly enhance the editor's code completion, etc.
  • Show Dependency Graph - Run this and show the graph. It helps if your organize the dependencies ahead of time and Save the Layout.

Creating a New Maven Project

  • Create a new Maven2 project
  • Choose Simple webapp project
  • Name the project MyWebApp
  • Show the Run properties (deployment server)
  • Run the project

Demo Cleanup

These are the necessary steps to take in order to successfully run the demo again on the same machine.

  • Delete the MyWebApp project. Note that this cannot be done from within the IDE like it can for Ant-based projects. Close the project in the IDE and then outside of the IDE remove the project directory.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo