So, I was more than a little disappointed to discover that the Grails developers are using Ant for most of the command-line stuff (partly because I was hoping to learn some cool tricks for starting up HSQLDB and Jetty for Chama). It just seems a little weird to me to rely on Ant tasks to do something that in my mind should be handled as part of the class (or Groovy file in this case).
Here are some examples of what I’m talking about:
<target name="run-app:impl">
<basename property="project.dir" file="."/>
<groovy>
import org.mortbay.jetty.*
import org.mortbay.http.*
System.setProperty('org.mortbay.xml.XmlParser.NotValidating', 'true')
def server = new Server()
project.addReference('server', server)
try {
def listener = new SocketListener()
listener.setPort(properties.'server.port'.toInteger())
server.addListener(listener)
server.addWebApplication("/" + properties."project.dir", 'tmp/war')
server.start()
} catch(Throwable t) {
t.printStackTrace()
}
</groovy>
</target>
I can understand, to a certain degree, why one would do something like this, but this seems like a bit overkill. I have a real problem with adding scripting into Ant files, it just seems like you are really pushing Ant to do something that it was never meant to do, but that’s just my opinion.
Also, to be fair, the Grails developers seem to have realized this and are now moving towards a true command line interface with the GrailsScriptRunner.groovy. Again though they are tying themselves to Ant unnecessarily. My personal preference is to create a true standalone command line interface (which is what I’m doing with Chama).
These are, of course, my opinions but I thought that others not familiar with Grails might be interested. And also note that I loathe Ant
, I’m a true Maven convert.