10 Steps to Happiness with Maven and the NetBeans Platform
By Geertjan-Oracle on May 23, 2008
Now let's create our first NetBeans Platform application via the tailor-made NetBeans Platform Maven archetype provided by the NetBeans Maven plugin for NetBeans IDE 6.1.
- Start NetBeans IDE 6.1 and install the Maven plugin (Tools | Plugins | Available Plugins).
- Go to the New Project wizard (Ctrl-Shift-N) and choose Maven | Maven Project and then click Next.
- Choose "Maven Netbeans Platform Application Archetype":
- Very important: Don't forget to fill out the details at the bottom of the dialog:
The 'brandingtoken' and the 'cluster' could be set to anything. The 'brandingtoken' is used during the customization phase of your application, i.e., to distinguish it from other applications. You need to set this here so that you're aware of what the token is later. However, this will not be very important to you (at all) in the greater part of your development process. The 'cluser' determines the name of the folder that will contain your custom modules, i.e., those that are in addition to the clusters of modules provided by the NetBeans Platform. Again, the cluster name is not very important and can be modified later anyway.
The 'netbeans-install' field is very important. Later, when you run the application, the application will need to know the location of a NetBeans installation. Above, I have set "/home/geertjan/netbeans-6.1" because that is the top level folder of my NetBeans installation.
Make sure that you press Enter for each of the fields, otherwise the entered text wont't "take" and the wizard will assume that the field is empty, causing problems later when you try to deploy it. There should be default values for all of the above fields; this is a known problem and will be fixed at some point.
- Click Finish and observe the two projects in the Projects window. The first is for the application and the second for a dummy module. You can use that module as your starting point and then add more as needed. Here's what you should see:
There's one small yet very important thing that should be tweaked (again, a known problem). Open the profiles.xml file that you see above. In there, you'll see an element named "netbeans.installation.directory":
Change that element name to "netbeans.installation". It is a known bug.
- Right-click the application and choose Build. It is very important that you do this, because the Run action won't do it for you, so that you'll have deployment problems in the next step if you haven't built the application first.
- Now right-click the application and choose Run. This will run the application and you'll see the splash screen of NetBeans IDE 6.1 and then your new application:
Now, even though our first module doesn't do anything yet, we'll add a second module to our application. To do this, we will need to create our new module in the same folder as where the application is found. Look at step 4 above and notice that we will need to create our new module in "/home/geertjan/NetBeansProjects/DemoRCPApp". OK, let's do it via a new archetype in the next step.
- Press Ctrl-Shift-N again and choose Maven | Maven Project | Maven NetBeans Module Archetype:
- Specify the location of the application, as pointed out above:
- Click Finish and now you can see that your application consists of two modules (in addition to the modules that the NetBeans Platform makes available):
Now refer to the two articles at the start of this blog entry which, together, should give you everything you need when working with Maven and the NetBeans Platform.