The Source for Java Technology Collaboration
User: Password:



Tim Boudreau

Tim Boudreau's Blog

Generate a NetBeans module for your library or JavaBeans in one Ant task

Posted by timboudreau on February 07, 2007 at 10:52 PM | Comments (10)

A while back I wrote a tool called BeanNetter that would take any library JAR file and generate a NetBeans module that added the library to the list of libraries you can use from your projects (a handy way to bundle source and Javadoc all together so people can debug). It also would add any JavaBeans in the JAR to the Matisse (Swing GUI Designer) component palette. Well, it is now also an Ant task. So you can make it part of the build process for any library to also generate a NetBeans module. Mobile Bay, Mobile, AL, USA

This afternoon I got an email from Mikael Grev about the tool, and asking if there was an Ant task. I'd planned to do one but hadn't gotten around to it. This afternoon I finally did.

It can still benefit from some prettification, but it's ready to try. You can download it here.

Easy way to use it: The first time, just run the GUI using java -jar beans2nbm.jar and point it at the files for the library you'd like to bundle into a NetBeans module. At the end of the wizard, on the summary page, it will show all the necessary Ant code to replicate what it just did (and include the text you entered in the wizard). Just tweak the paths to be relative to your build script and paste it there.

For examples, the Quick Color Chooser and Wizard projects are now set up with build scripts to use the task. Here is the ColorChooser build script.

Please try it - comments and feedback are most welcome! And many thanks to Mikael for the suggestion!

For convenience, here is a sample target:

    <target name="nbm" description="Generate a NetBeans Module" 
        depends="jar,release-javadoc">

        <taskdef classpath="lib/beans2nbm.jar" 
            classname="beans2nbm.ant.GenNbmTask" 
            name="nbm"/>
          <zip zipfile="dist/colorchooser-src.zip">
              <fileset dir="src">

                  <exclude name="**/CVS"/>
              </fileset>
          </zip>
        
        <nbm destFolder="dist" 
            destFileName="net-java-dev-colorchooser.nbm" 
            description="A color chooser" 
            version="1.1" 
            homepage="http://colorchooser.dev.java.net"

            codeName="net.java.dev.colorchooser" 
            jarFileName="dist/colorchooser.jar" 
            author="Tim Boudreau" 
            displayName="Color Chooser" 
            license="CDDL"
            docsJar="www/release/colorchooser-javadoc.zip"

            sourceJar="dist/colorchooser-src.zip"
            minJDK="1.4"/>
    </target>
Mobile Bay, Mobile, AL, USA

Mobile Bay, Mobile, Alabama


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Tim,
    The turn-around time for this was amazing! Thanks!

    The task is working flawlessly. The wizard however doesn't show that last task config page. It creates the .nmb but stays on the last page (the one with the Destination Folder and I have to press cancel. No biggie though as the task settings are trivial.

    I'm not sure this is even possible to do with a NB module, but it would be really nice if one could:

    1) Specify one .jar that is to be used for development (containing the PropertyEditors and BeanInfos) and another for deployment. Our deployment .jar is 30% smaller..
    2) Include example projects. This would make it a lot easier for the potential user.

    Anyways, I'm really impressed with our response time and I've already integrated the ant tast in MiG Calendar's build process. :)

    Cheers,
    Mikael

    Posted by: mikaelgrev on February 08, 2007 at 02:12 AM

  • Oh, FYI, there are a few magic license names: cddl, gpl, lgpl, apache, bsd, and artistic. For any of those it will automatically include the correct license text (when your module is installed there is a click-through).

    Otherwise you can specify the attribute as license text (that would have to be a really short license), or as a relative or absolute path to the license file.

    Posted by: timboudreau on February 08, 2007 at 02:32 AM

  • %gt; or as a relative or absolute path to the license file.
    Excellent, I was kind of worried about that.

    "I'm really impressed with our response time..."
    should be "I'm really impressed with YOUR response time" :)

    Posted by: mikaelgrev on February 08, 2007 at 03:11 AM

  • Is the sourcecode available?
    I'm looking for a way to create a netbeans-project out of our own project-structure (with ant). It's very tedious to use the graphical-wizards in netbeans for this task because our own project-structure doesn't match netbeans's and I have to click a lot. So having a ant-task that would import sources and resources (for in the classpath) would help enourmous.

    Posted by: keeskuip on February 08, 2007 at 10:54 AM


  • cvs -d:pserver:anoncvs@cvs.netbeans.org:/cvs co contrib
    cd contrib/Beans2nbm/beans2nbm

    I won't say it's pretty, and it's pretty geared towards the specific thing this code does - but basically all it does is make model objects for the files it creates and write them into the zip stream. The Ant task (I said it wasn't pretty) stores all the properties in a Map, so that the code that was expecting a Map of data gathered from a wizard UI as the user traversed the wizard's pages can easily work with it from the Ant task. There's not much that's likely to be useful for general-purposes, but if you can make use of it, go for it.

    Posted by: timboudreau on February 08, 2007 at 11:14 AM

  • I think it should be contrib/BeanToNbm/Beans2nbm. There seems to be two adjacent levels there, not sure which one is the latest...

    Posted by: mikaelgrev on February 08, 2007 at 11:22 AM

  • FYI, I've updated the JAR - it now also allows you to explicitly specify the list of classes that should be on the component palette, nested inside the target, e.g.

    <bean>org/foo/MyBean.class</bean>

    An example can be found here.

    Posted by: timboudreau on February 09, 2007 at 12:10 PM

  • This tools can simplify a lot of things in my work. Does it accept multiple jar files?

    Posted by: fabriziogiudici on February 12, 2007 at 06:43 AM

  • Not at present. Wouldn't be too hard to add.

    Posted by: timboudreau on February 12, 2007 at 03:52 PM

  • I'm looking for a way to create a netbeans-project out of our own project-structure (with ant). It's very tedious to use the graphical-wizards in netbeans for this task because our own project-structure doesn't match netbeans's and I have to click a lot.

    [porn urls deleted - ed.]

    Posted by: maripikos on June 17, 2007 at 01:44 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds