groovy

How best to get map from key list/value list in groovy?

In python, I can do the following: keys = [1, 2, 3] values = ['a', 'b', 'c'] d = dict(zip(keys, values)) assert d == {1: 'a', 2: 'b', 3: 'c'} Is there a nice way to construct a map in groovy, starting from a list of keys and a list of values? ...

Website for Groovy Katas

Am planning to learn Groovy the Kata way. Is there any source similar to RubyQuiz for Groovy Katas ? ...

unable to find com.sun.grizzly.tcp.http11.GrizzlyAdapter.setResourcesContextPath(String)

I trying to expose some groovy service with jersey and girzzly. but i got a wierd error when i'm launching my servlet container. Here is the snippet which lauch it: ServletAdapter adapter = new ServletAdapter(); Injector injector = Guice.createInjector(new GmediaModule()); GuiceContainer container = new GuiceContainer(injector); adapte...

groovy or java: how to retrieve a block of comments using regex from /** ***/?

Hi, This might be a piece of cake for java experts. Please help me out: I have a block of comments in my program like this: /********* block of comments - line 1 line 2 ..... ***/ How could I retrieve "block of comments" using regex? thanks. ...

Using Gaelyk URL routing in a non google app engine application

I have a Groovy Web application which is NOT being deployed on Google app engine. (GAE) I have used Gaelyk before and I like the URL routing functionality described in their doc How do I port over just the routing functionality from Gaelyk to my basic Groovy WEB application which is not being deployed on GAE? Note 1: I also do not wan...

What are the advantages of writing a Maven plugin in Groovy compared with Java?

Hi, I'm about to write several Maven plugins to ease the life of the R&D people. I'm contemplating between writing the plugin in Groovy or in Java. The plugin would most likely need to: Use Git commands such as checkout, clone, etc. Download pom.xml files of specific artifacts from a remote repository (our internal Nexus) Parse the p...

Groovy grape installation

I installed HTTPbuilder using grape, D:\Documents and Settings\Administrator>grape install org.codehaus.groovy.module s.http-builder http-builder 0.5.0 :: loading settings :: url = jar:file:/D:/Program%20Files/Groovy/Groovy-1.7.4/li b/ivy-2.2.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml :: resolving dependencies :: caller...

Best dynamic language to pair with Java on a Java project

What is the best dynamic language to pair with Java on a large Java project? We are considering using a dynamic language for tests, controllers, services. Some options are Groovy, JRuby or Jython. What are the pros and cons of each for this? Ideally we'd be able to call Java from the dynamic language as well as call the dynamic langu...

reading Google calendar values

I have set an event successfully using myEntry.setTitle(new PlainTextConstruct("TEST")) myEntry.setContent(new PlainTextConstruct("See how much text will fit in there")) Then I have successfully read the event record. This works myTitle = ret.getTitle().getPlainText() But this throws an error myTitle = ret.getContent().getPlainTe...

Groovy static generic type

I've been playing around with getting rid of DAOs in favor of ActiveRecord like entities in Java, but generics won't allow me to have the full functionality that I want (like static finders). Somehow Groovy does, but I'm confused why. Given the following: class ActiveRecord<T> { static Class<T> genericType; ActiveRecord() { ...

Groovy: Setting property values easily

I have a map with name/value pairs: def myMap = [ "username" : "myname", "age" : 30, "zipcode" : 10010 ] I have a class called User defined: class User { def username; def age; def zipcode; } I would like to invoke the appropriate setters on the bean. Is there a nice groovy way of doing this? Note, I might have extra...

Soap in Groovy - keep getting NoSuchMethodError

Newbie question: I'm new to groovy & soap , so I might be missing out on something here: I'm trying to communicate with a very basic web service : import groovy.net.soap.SoapClient ... def proxy = new SoapClient("http://soapclient.com/xml/soapresponder.wsdl") res = proxy.Method1("ABC", "123"); println (res); It seems the connect...

Keep JSPX from creating self closing tags (<div></div> != <div/>)

JSPX has the lovely side effect of turning: <div class="magic"></div> Into: <div class="magic" /> For many browsers this causes pandemonium and mayhem with layout even though it is valid XHTML. Consequently I have resorted to using a groovy script to find all possible bad HTML with the following regex: def m = html =~ /<(\w+)[^>]...

Groovy split() method bug ?

Hi, The following Groovy snippet produces weird results to me : def s = "123456" assert s.split("").size() == s.size() Results in : Assertion failed: assert s.split("").size() == s.size() | | | | | | | | 7 | | 6 | | | 123456 | | false | [,...

Groovy time durations

Hi I'm trying to calculate the difference (duration) between two times in Groovy. e.g. start = "2010-10-07T22:15:33.110+01:00" stop = "2010-10-07T22:19:52.356+01:00" Ideally I would like the get the duration returned in Hours, Minutes, Seconds, Milliseconds. Can anybody please help. I've tried to use Groovy's duration classes but ...

Griffon integration test or script that displays a griffon View

When I create plane java Swing components like dialog boxes etc, it is very easy to make a unit test to display the Dialog. Basically, I can just create an instance of the dialog and call setIsVisible(true). I'm having a really tough time figuring out how to do this with a griffon View. I've been trying to do this with integration tes...

Grails Secure Login Design Questions along with Library & DB Choice

Hello, Am planning on building user administration module using Grails and the Spring Security Core plug-in for Grails. Also, am considering using MongoDB for the database system. Question(s): (1) What trade offs and benefits will my app gain by choosing MongoDB over MySQL or HSQLDB? (2) Is it super easy to way to implement (meaning...

Groovy Time durations

Hi, I'm trying to get the difference between 2 dates in days, hours, and seconds: import groovy.time.* Date now = new Date() // Using deprecated constructor just for this example Date newYearsDay2000 = new Date(2000, 0, 1) use (TimeCategory) { now - newYearsDay2000 } This prints: -690023 days, -14 hours, -38 minutes, -27.1...

Execute my groovy script with ant or maven

I have the following 1 java class 1 bat file (starts the groovy script) 1 groovy file All is in the same folder Now I want to use Maven or Ant to run the groovy file but I cant get it to work. Is there someone who can show me how to write this pom.xml or build.xml? I dont want to use the bat file anymore. ...

Can I override a constructor using metaprogramming limited to a scope in groovy?

I'd like to override the constructor of a class for testing. I can do it like this: SomeClass.metaClass.constructor = { Map params -> def instance = BeanUtils.instantiateClass(SomeClass) instance.apply(params) instance } That works, but I need the new constructor to apply to only some instances. In particular, I'd ...