Tuesday April 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:
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}"/>
</target>
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
<featuredefs>
<featuredef name = "RMICompiler"customizerClassRef = "rmiext-RmiextCustomizer.instance">
<title>RMICompiler</title>
<icon>rmiext/rmi.png</icon>
<project>
<type>org.netbeans.modules.java.j2seproject</type>
</project>
<actions>
<anttask>
<name>rmi-post-compile</name>
<title>RMI Compiler</title>
</anttask>
</actions>
<dependsOn>
<anttask>rmi-post-compile</anttask>
<featureName>org.netbeans.modules.java.j2seproject</featureName>
<anttaskInFeature>-do-compile</anttaskInFeature>
</dependsOn>
<dependsFrom>
<anttask>rmi-post-compile</anttask>
<featureName>org.netbeans.modules.java.j2seproject</featureName>
<anttaskInFeature>-post-compile</anttaskInFeature>
</dependsFrom>
<usedtargets>
<usedtarget>rmi-post-compile</usedtarget>
</usedtargets>
<velocityTemplate vmFile = "Rmiext.vm"/>
</featuredef>
</featuredefs>
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}"/>
</target>
And references are added to layer.xml
<filesystem>
<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"/>
</folder>
</folder>
</filesystem>
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.
Posted by xzajo ( Apr 11 2006, 11:09:16 AM CEST ) Permalink Comments [19]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 .
Posted by xzajo ( Apr 10 2006, 05:35:40 PM CEST ) Permalink Comments [14]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.
Posted by xzajo ( Apr 07 2006, 02:41:53 PM CEST ) Permalink Comments [142]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() {
Assert.fail("failure");
}
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.
Posted by xzajo ( Apr 03 2006, 08:22:13 PM CEST ) Permalink Comments [196]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:
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.
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.
Posted by xzajo ( Mar 24 2006, 11:58:49 AM CET ) Permalink Comments [61]