Maven-based NetBeans platform development with JRebel 6 – minor update

Some months ago I wrote about how easy it is to use JRebel for development of NetBeans platform module [1]. That article was focused mainly on standard ant-based modules. But recently I started to convert my plugins to the maven-based approach. At the same time I started testing JRebel 6 in an EAP. This combination didn’t work as described in one of my previous blog entries [2], but I figured it out and I like to document it using this blog post.

Steps to get maven-based nbms running using JRebel 6

  • enable “compile on save”
  • generate rebel.xml to /src/main using the context menu of jrebel (this way it will be copied to target/classes)
  • alter the properties-section of the pom.xml like this
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <netbeans.run.params.ide/>
            <netbeans.run.params>-J-noverify -J-javaagent:e:/tools/jrebel/jrebel.jar -J-Drebel.log=true ${netbeans.run.params.ide}</netbeans.run.params>
        </properties>
    
  • run the module – JRebel will create a bootstrap file in your temp directory once and will quit the execution
    JRebel: Starting logging to file: C:\Users\markiewb\.jrebel\jrebel.log
    [INFO] JRebel is now building a boot class cache.
    [INFO] This will only happen on this first run, or after manually deleting the rebel boot folder.
    [WARNING] JRebel bootclasspath not specified!
    [WARNING] Make sure to add -Xbootclasspath/p:C:/Users/markiewb/AppData/Local/Temp//rebelboot.jar to jvm arguments
    [WARNING] Otherwise this warning will appear again, and you won't be able to start your application
    [INFO] System will exit now, please restart the application to run with JRebel enabled.
    
  • add the bootclasspath argument with the path from the previous output to netbeans.run.params too (please note the “-J” prefix, that is important) (If NetBeans does not start, try to remove ${netbeans.run.params.ide} from the <netbeans.run.params>-parameter
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <netbeans.run.params.ide/>
            <netbeans.run.params>-J-noverify -J-Xbootclasspath/p:C:\Users\markiewb\AppData\Local\Temp\rebelboot.jar -J-javaagent:e:/tools/jrebel/jrebel.jar -J-Drebel.log=true ${netbeans.run.params.ide}</netbeans.run.params>
        </properties>
    
  • run the module – the application with your module and JRebel should start up
  • make changes to your classes and jrebel will pick them up

Tested with Win7 64bit, Oracle JDK 1.7.0u40, JRebel 6.0.0-M3, NetBeans IDE 7.4

 

Updates:
15/Mar/2014:

  • Tested with Win7 64bit, Oracle JDK 1.7.0u45, JRebel 6.0.0-M6, NetBeans IDE 7.4Patch2
  • Added comment about removing ${netbeans.run.params.ide}

[1] https://benkiew.wordpress.com/2013/05/01/netbeans-platform-development-with-jrebel-even-more-simplified/
[2] https://benkiew.wordpress.com/2011/12/28/netbeans-module-development-with-jrebel/

Advertisements

How to convert an ANT-based NetBeans Module to a Maven-based NetBeans Module

I am currently converting some of my ANT-based NetBeans Modules to Maven-based ones. I didn’t found a step-by-step migration list, so I decided to create one and to share it with you. The following list was created while converting a simple plugin with less than 20 classes, so the migration steps of large projects might vary. But you should get the basic idea.

  • create a new maven based NBM using the “New Project”-wizard (to reuse a working configuration)
  • copy the folder src and pom.xml to the old project
  • in pom.xml
    • define a groupId
    • set the name from OpenIDE-Module-Name entry in Bundle.properties
    • set the artifactid from OpenIDE-Module entry in MANIFEST.MF
    • set the version from OpenIDE-Module-Specification-Version entry in MANIFEST.MF
  • remove the line with OpenIDE-Module-Specification-Version entry from MANIFEST.MF
  • remove the line with OpenIDE-Module entry from MANIFEST.MF
  • remove nbproject/genfiles.properties
  • remove nbproject/platform.properties
  • remove nbproject/build-impl.xml
  • remove build.xml
  • move manifest.mf to folder src/main/nbm
  • move your sources (*.java) to src/main/java (or src/test/java) (GIT is very useful here, the commit history isn’t lost)
  • move your resources (not *.java) to src/main/resources (or src/test/resources) (especially Bundle.properties)
  • add dependencies (the most annoying part)
    • foreach dependency entry (code-name-base) in nbproject/project.xml add a dependency via the “Add dependency” dialog OR add a dependency manually to pom.xml

    For example use

    <dependency>
      <groupId>org.netbeans.api</groupId>
      <artifactId>org-netbeans-modules-projectapi</artifactId>
      <version>RELEASE73</version>
    </dependency>

    for

    <dependency>
      <code-name-base>org.netbeans.modules.projectapi</code-name-base>
      <build-prerequisite/>
      <compile-dependency/>
      <run-dependency>
          <release-version>1</release-version>
          <specification-version>1.46.1</specification-version>
      </run-dependency>
    </dependency>

    (!) Note that the dots in the dependency name have to replaced by a dashes

  • add test dependenciesFor example use
    <dependency>
        <groupId>org.netbeans.api</groupId>
        <artifactId>org-netbeans-libs-junit4</artifactId>
        <version>RELEASE73</version>
        <scope>test</scope>
    </dependency>

    for

    <test-dependencies>
        <test-type>
            <name>unit</name>
            <test-dependency>
                <code-name-base>org.netbeans.libs.junit4</code-name-base>
                <compile-dependency/>
            </test-dependency>
        </test-type>
    </test-dependencies>

There is still more to do. Like to configure export packages, signing, homepage and so one. Most of these configuration settings defined in the original project.properties have a counterpart in the plugin configuration of the nbm-maven-plugin. See the detailed goal documentation at http://mojo.codehaus.org/nbm-maven/nbm-maven-plugin/nbm-mojo.html

But your mavenized plugin should start at least now.

PS: The whole process is worth a plugin itself.  Any volunteer?