views:

1834

answers:

1

What's the best way to convert NetBeans (Matisse) .form files into .java files, without using the NetBeans IDE itself? Ideally I'd like to package the .form files along with my source code, and generate the .java files at build time. This will prevent developers from "accidentally" adding code to the generated .java file using some other IDE, which could then get overwritten by NetBeans the next time the form itself is edited in the GUI designer.

I've searched Google and all I can find is people saying, "Use the NetBeans IDE to generate the .java file," which is kind of difficult to do at build-time.

+1  A: 

Well, actually having to fight with "accidental" addition of codes is more a problem of process rather than a problem with technology. My steps would be:

  1. Prevent committing the generated .java files in the CVS/SVN repository
  2. Embed matisse form generation in a continuous integration project.

For step 1: Use a sensible naming convention and stick with the standard for all the gui object, e.g.: put all the forms inside a common package and use the .svnignore directive on java files in it.

For step 2: Fabrizio Giudici has a nice tutorial on how to build a netbeans project (yes using matisse) inside a continuous integration environment.

http://weblogs.java.net/blog/fabriziogiudici/archive/2006/11/setting_up_netb.html

Note that he talks about installing netbeans first on a machine with a gui then moving the jar files in an headless machine. IIRC it was possible to install Netbeans version 4.x in an headless environment without using the gui (since it is a java application, the only steps to do were to unzip the files and create a sensible shell file launching the application with the correct jvm/classpath combo).

Anyway, if you can't enforce both rules, or you can't find how to generate the matisse artifacts in the CI server, consider the possibility to scrap the use of matisse entirely.

Davide Inglima
Unless I'm missing something, Giudici's blog entry only describes including the "swing-layout.jar" dependency (which the generated Java files require), not how to generate the Java files themselves. Thanks for your answer, though!
Ross