Geertjan's Blog

  • August 1, 2008

"grails netbeans"

Geertjan Wielenga
Product Manager
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.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.