Tuesday Apr 11, 2006

Project Extensions (natures) Wizard for NetBeans 5.0

Project Extensions plugin is implementation of project natures for NetBeans 5.0. Project natures extends functionality of NetBeans projects. Currently it consists of these features:

  • Adding new ant tasks to project's build script
  • Specification of ant tasks dependencies in project's build script, for example the ant task is executed before -post-compile task.
  • Extending the classpatpath of project.
  • Allow to either download libraries from remote library repository (for example maven1) or specify root of repository on local filesystem (for example hibernate installation).
  • A project extension is represented with a node in Project Extensions window.
  • Customizer for Project extension
I've already blogged about few Project Extensions ( Test NG, Java HelpSet validation, Emma code coverage). All these extensions were created with Project Extension Wizard.

To create new project extension is very simple with Project Extension Wizard. It will be demonstrated on creating RMI project extension for J2SE project. The Java RMI (Remote Method Invocation) system allows an object running in one Java Virtual Machine (VM) to invoke methods on an object running in another Java VM. It is necessary to generate stub and skeleton classes using rmic compiler to establish connection between client and server parts. The rmic compiler must to be run on compiled class of implementation of RMI object.

At first we create simple J2SE project with modified build script. We add two new ant's tasks to main build script (build.xml in root folder of project) :

  <target name  = "-post-compile" depends  = "rmi-post-compile"/> 
     <target name  = "rmi-post-compile" depends  = "-do-compile"> 
         <property name  = "remote.impl.filter" value  = "\*\*/\*RemoteImpl.class"/> 
         <rmic base  = "${build.classes.dir}" includes  = "${remote.impl.filter}"/> 

The -post-compile ant task is empty because the project extension wizard doesn't copy the standard project ant tasks to the project extension template. We can to create implementation of a RMI service and test it now. We expect that everything is alright.

Now it's time start to create a project extension using project extension wizard:

In the second Panel select the project with modified build script and clicked to Next button. After clicking to Next button Customize Project Extension Panel is shown.

The wizard automatically parses the modified build script and shows all new targets. The -post-compile is not added to table with available ant tasks because more project extensions cannot override the same target. Only dependencies between targets are stored to dependencies table.

If we assign to ant target display name the target will be represented by action in popup of project extension node in Project Extensions window. There is not necessary to change dependencies between targets. It will be usefull for example when dependencies between different Project extensions are defined. Click to next button you can specify classpath for the project extension. The libraries are got from Library manager.

RMI doesn't need extra library on the classpath. Click to Next button to show the last panel of wizard. There can be specified the name, display name, icon, post create action and customizer. The post create action is invoked after adding project extension to project. It is useful for example when it is necessary to initialize some properties. The customizer panel is shown in JDialog when is performed Properties action from project extension node.

After clicking to "Finish" button the Project extension template will be generated.

rmiext.xml - descriptor

     <featuredef  name =  "RMICompiler"customizerClassRef = "rmiext-RmiextCustomizer.instance"> 
                 <title>RMI Compiler</title> 
         <velocityTemplate vmFile = "Rmiext.vm"/> 

rmiext.vm - velocity template
<target name="rmi-post-compile">
  <property name="remote.impl.filter" value="\*\*/\*RemoteImpl.class"/>
  <rmic base="${build.classes.dir}" includes="${remote.impl.filter}"/>
And references are added to layer.xml
     <folder name = "velocity"> 
         <folder name = "build"> 
             <file name = "Rmiext.xml"url = "Rmiext.xml"/> 
         </folder > 
         <folder name = "customizers"> 
             <file name = "rmiext-RmiextCustomizer.instance"/> 
         </folder > 
         <folder name = "templates"> 
             <file name = "Rmiext.vm" url = "Rmiext.vm"/> 

The project extension was created. No line of of code was written. So we can try to run the module. And Test the nature. The Nature can be added to project from popup in Project Extensions window.

The project extension node is shown bellow.

The RMIC compile is not run either on project building or from RMI Project extension popup.

This wizard is available in NBXdoclet Modules Development plugin. The plugin available on my update center. The NBXdoclet Modules Development plugin depends on NetBeans Module Development Environment U1.

Monday Apr 10, 2006

NetBeans JavaHelp Set Wizard with validation

In NetBeans Develoment Support Update 1 was introduced JavaHelp Set Wizard with validation.

It generates java help and save a lot of time. To tell you truth I started to write help for my pluging with the JavaHelp Set wizard. I was too lazy to set up the java help files manually.

Modules in NetBeans CVS uses different harness than the harness from NetBeans 5.0. It contains ant target for validation help IDs. But what to do in not netbeans CVS modules? I am too lazy to check the IDs manually that I copied the ant tasks. I've created Java Help Set Project extension.

The NetBeans Harness Extension plugin is available on my update center .

Friday Apr 07, 2006

Try TestNG 4.6 with NetBeans 5.0

Today I have good news for TestNG community. First testing build of TestNG Support 4.6 for NetBeans 5.0 is available on my update center. Plugin with my update center is available here. I've already wrote quick tutorial in previous record about TestNG plugin for NetBeans 5.0.

Please let me know about any problems and possible improvements on nbxdoclet's forum.

Monday Apr 03, 2006

Test NG plugin for NetBeans 5.0

I finished Test NG project extension for NetBeans 5.0 yesterday in train from Ostrava to Prague. I would like to commit it into cvs because I cannot access to CVS server on sourceforge.net. Probably ssh server is down :(. I'll try describe how to use this plugin:

Create New Test NG case from template:

Generated code of test is here :

package sd ;

import org.testng.Assert;
import org.testng.annotations.Configuration;
import org.testng.annotations.ExpectedExceptions;
import org.testng.annotations.Test;

public class NewTest {
  @Configuration(afterTestClass = true)
  public static void tearDownClass() {

  @Configuration(afterTestMethod = true)
  public void afterTestMethod() {

  @Test(groups = { "My group" })
  public void testMethod1() {

The Test NG Project Extension is automatically added to project extensions. There are two action for the extension - Run Tests and Show Results. Look at the snapshot:

Results are shown in web browser:

How to install and download the plugin is here.

Tuesday Mar 28, 2006

Select J2SE library from Maven repository and install it in NetBeans 5.0 feature

Project extensions plugin of NBXdoclet allows to select library from Maven repository and install it to Library Manager.

For example you want to add Postgresql jdbc driver to my project. Dialog with available libraries is shown by using Tools|Download Library menu item from main menu. There are these components:

  • left list - Category with similar libraries
  • center list - Libraries in selected Category
  • right list - libraries which will be installed. A library should be removed or added using >> or << buttons
  • library filter filter, shows only folders which contains libraries with matched string

To filter contentes of all librarires type pos int Filter field. After selection of postgresgl Category all libraries from postgress category are shown in libraries folder. Select the postgresql-7.2.jar and click to >> button. The Library is added to Added libraries list. To start downloading and installing the library click to Ok button. Waiting dialog with progress bar is shown during installing of library.

When is the library downloaded we can add the library to our project.

Friday Mar 24, 2006

Emma Code Coverage for NetBeans 5.0 plugins

EMMA is an open-source toolkit for measuring and reporting Java code coverage. Netbeans Project Extensions Project allows to create pluggable extensions for NetBeans projects. One of first extensions is support for code coverage of test's run in NetBeans 5.0.


  1. Download sf-netbeans-nbxdoclet-update-05.nbm NetBeans plugin. Install it. The plugin contains url to nbxdoclet update center.
  2. Open update center and install Experimental Teplates plugin with its dependencies.

How to use Emma code coverage

  1. Show project extension window from Window|Project Extension main menu.
  2. Select your developed module.
  3. Select Project Extensions Window.
  4. Perform Add Project Extension from popup of Project Extensions Window. Dialog with available project extensions is shown.
  5. Select Emma Code Coverage item from list and click to Ok button. The Emma Code Coverage Project Extension is added to selected project. It is visible in Project Extensions Window
  6. Select Emma Code Coverage node in Project Extensions Window and perform Run Code Coverage action from popup dialog. The tests are run and the emma code coverage report is generated.
  7. if some tests were run you can show code coverage results by clicking to Show Results from popup of Emma Code Coverage node.




« July 2016