Friday Aug 01, 2008

"grails netbeans"

In the last few days, I've blogged about Groovy scripts that generate application source structures. As examples, I used a Groovy script that generates a skeleton NetBeans Platform application and a Groovy script that generates a skeleton NetBeans module. At this point, it should be possible for me to put the scripts into the Grails "scripts" folder, create a GANT script that calls the Groovy scripts, and then run this command from the command line:
grails netbeans

Then a script named "Netbeans.groovy" should run. However, global scripts of this kind cannot be created, currently. Only a small subset of such commands are permissible, since they're hardcoded into the applicable class. So, although I can run "grails create-app" and "grails help", for example, I can't currently run "grails netbeans". (See the helpful explanation here for details.)

So, there's currently three solutions: (1) Be satisfied with application-level scripts, which can have any name at all, and forget about global scripts; (2) Copy your script into one of the permitted global scripts (i.e., copy your "Netbeans.groovy" code into the "CreateApp.groovy", for example); (3) Rewrite the Java source code ("GrailsScriptRunner.java") and recompile the library to create a new JAR and replace the old one in your Grails distribution with the new one.

The first solution wasn't good enough for me, while the third is too much work. So now I can run "grails create-plugin" and I get the sources of a NetBeans module. I simply replaced the content of "CreatePlugin.groovy" with this:

grailsHome = Ant.antProject.properties."env.GRAILS_HOME"    
includeTargets << new File ( "${grailsHome}/scripts/Netbeans.groovy" )

target ( "default" : "Message at the end of it all.") {
   println 'Finished!'
}

Note the line in bold above. That pulls in the Groovy script that generates the skeleton NetBeans module. The only remaining question I have is: what must I do if my Groovy script is making use of a GroovyBuilder? The above "Netbeans.groovy" script actually works via a GroovyBuilder. Couldn't get them to work together within this content, however.

In other news. If you're a fan of Groovy and Grails and want to see it in action with MySQL in the context of NetBeans IDE, click here for a truly amazing article.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« August 2008 »
SunMonTueWedThuFriSat
     
2
4
5
6
7
11
14
17
20
23
27
29
30
31
      
Today