Re: Juglist Digest, Vol 70, Issue 5
Marvin Bautista <[email protected]> Tue, 19 Jul 2011 15:33:53 -0400
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Message-ID | <[email protected]> |
Thanks for researching on questions Andy! I tried this approach early this year but <grails environment=""> did not work at the time (it always set to dev no matter what). I'm glad to know this is working now. Need to create task to incorporate this in our process. Thanks again! -Marvin On Jul 19, 2011, at 3:00 PM, [email protected] wrote: > Send Juglist mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > http://trijug.org/mailman/listinfo/juglist_trijug.org > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Juglist digest..." > > > Today's Topics: > > 1. Grails apps with Ant / Hudson / etc. (Phillip Rhodes) > 2. Groovy Answer to my embedding question (Andrew Oliver) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 18 Jul 2011 22:31:31 -0400 > From: Phillip Rhodes <[email protected]> > To: "Triangle Java User's Group" <[email protected]> > Subject: [Juglist] Grails apps with Ant / Hudson / etc. > Message-ID: > <CAO3ErG-1QvQP5f8k-yGnDq672kX+oh7u+5QZbEpJVGbKt59CJQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> > Content-Type: text/plain; charset="iso-8859-1" > > 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 > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: <http://trijug.org/pipermail/juglist_trijug.org/attachments/20110718/ffed1e1d/attachment-0001.html> > > ------------------------------ > > Message: 2 > Date: Tue, 19 Jul 2011 09:17:01 -0400 > From: Andrew Oliver <[email protected]> > To: trijug discussion <[email protected]> > Subject: [Juglist] Groovy Answer to my embedding question > Message-ID: > <CAF9=+5OmRbdY-koFCEAwiT5WCHHQBL6KXSo+Xt8iPfWi3XBJgQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> > Content-Type: text/plain; charset=ISO-8859-1 > > http://groovy.codehaus.org/Embedding+Groovy > > There appear to be two main ways to pass data between the embedded > groovy and Java > > Binding > > // call groovy expressions from Java code > Binding binding = new Binding(); > binding.setVariable("foo", new Integer(2)); > GroovyShell shell = new GroovyShell(binding); > > Object value = shell.evaluate("println 'Hello World!'; x = 123; return > foo * 10"); > assert value.equals(new Integer(20)); > assert binding.getVariable("x").equals(new Integer(123)); > > or with the GroovyClassLoader: > > ClassLoader parent = getClass().getClassLoader(); > GroovyClassLoader loader = new GroovyClassLoader(parent); > Class groovyClass = loader.parseClass(new > File("src/test/groovy/script/HelloWorld.groovy")); > > // let's call some method on an instance > GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance(); > Object[] args = {}; > groovyObject.invokeMethod("run", args); > > It appears that the variables would be passed in and wrapped. > > -Andy > > > > ------------------------------ > > _______________________________________________ > Juglist mailing list > [email protected] > http://trijug.org/mailman/listinfo/juglist_trijug.org > > > End of Juglist Digest, Vol 70, Issue 5 > **************************************