Grails apps with Ant / Hudson / etc.

Phillip Rhodes <[email protected]> Mon, 18 Jul 2011 22:31:31 -0400
Newsgroups gmane.org.user-groups.trijug.juglist
Message-ID <CAO3ErG-1QvQP5f8k-yGnDq672kX+oh7u+5QZbEpJVGbKt59CJQ@mail.gmail.com>
At tonight's meeting, somebody was asking a question about using Grails with
CI environments like Hudson, etc.

FWIW, this approach should work.  Create a build.xml
and plug in the classpath and taskdef stuff from this page
<http://grails.org/doc/latest/api/grails/ant/GrailsTask.html>

They don't point it out explicitly, but you'll probably want to set a
grails.home
property, since their example of actually *using* the task shows using
such a property.


Once you have that,  you can do stuff like this:

   <target name="compile">
     <grails environment="production" home="/usr/java/grails-1.3.7"
script="Compile">
     </grails>
   </target>

   <target name="run">
     <grails environment="production" home="/usr/java/grails-1.3.7"
script="RunApp">
       </grails>
   </target>

 <target name="test">
     <grails environment="test" home="/usr/java/grails-1.3.7"
script="TestApp">
       </grails>
   </target>

I may have missed part of the question, but I thought a big part of it was
something
like "how do you specify the environment you want?"  The "environment"
argument on the
grails task should take care of that.   When I ran this, I got:


[prhodes@voyager quoddy2]$ ant run
Buildfile: build.xml

run:
   [grails] Resolving dependencies...
   [grails] Dependencies resolved in 1975ms.
   [grails] Running script /usr/java/grails-1.3.7/scripts/RunApp.groovy
   [grails] SLF4J: Class path contains multiple SLF4J bindings.
   [grails] SLF4J: Found binding in
[jar:file:/usr/java/grails-1.3.3/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
   [grails] SLF4J: Found binding in
[jar:file:/development/projects/fogbeam/quoddy/quoddy2/lib/slf4j-jdk14-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
   [grails] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for
an explanation.

   [grails] Environment set to production

   [grails] No external configuration file defined.
   [grails]      [copy] Copying 1 file to
/home/prhodes/.grails/1.3.7.BUILD-SNAPSHOT/projects/quoddy2
   [grails]
   [grails]    [delete] Deleting directory
/home/prhodes/.grails/1.3.7.BUILD-SNAPSHOT/projects/quoddy2/tomcat
   [grails]
   [grails] Running Grails application..

Once you have targets for "compile" "test" etc., wiring
this into something like Hudson should be straightforward.


Cheers,


Phil

_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org