❯ Guillaume Laforge

groovy

New Groovy Snapshot

Since Groovy’s move from one server to another, we could not deliver the latest jars. We’re sorry for that, but we’re doing our best to fix all the little issues you’ve encountered (broken links, missing jar, etc) It’s not without difficulty that I managed to upload the latest snapshot of groovy, but I’m glad to announce that there is a new groovy-1.0-rc1-snapshot.jar. You can find it here: http://dist.codehaus.org/groovy/dist/groovy/jars/ If you’re still using beta-4, please upgrade to the latest snapshot. Read more...

A groovy web server

Based on a suggestion made by Jamie McCrindle, I decided it was time to add some missing Groovy methods related to sockets. So far, I have added a bunch of IO/streams methods enhancing the JDK core classes, but there were no methods dealing with sockets. But now, this time is over. I have added two methods: Socket.withStreams(Closure) which takes a closure as argument, and has acces to an input stream and an output stream, and ServerSocket. Read more...

Heads-up on File and Stream groovy methods

Over the week-end, I implemented new groovy methods, as defined in GROOVY-208 Plus a few complementary methods. getText(): BufferedReader.getText() File.getText() File.getText(encoding) Process.getText() You can now easily read the full content of a file or of a buffered reader and get it as a String. // retrieve the content of the file def content = new File("myFile.txt").text // you can specify the encoding of the file // note that since getText() has a parameter, // you cannot call it with something like text("UTF-8") content = new File("myFile. Read more...

Timing a closure in Groovy

When you want to make some optimizations to your code, you often use the good old System.currentTimeMillis() method to time certain parts of your application. I wanted to do a similar thing when hacking some Groovy scripts recently, and the idea came to me that I could simply create a timing closure! So here it is, for your eyes only: timer = { closure -> start = System.currentTimeMillis() closure() println System. Read more...

Happy Birthday Codehaus

A year ago, Codehaus saw the light of day. And since, it gathered a lot of bright and talented persons working on innovative and very good quality projects. And moreover, those projects have a friendly licence scheme (I’m not a GPL/LGPL lover). For a few months, I’ve been part of the Hausmates, thanks to my efforts in developing some code for Groovy, and I’m really proud of beeing part of it. Read more...

Groovy-JDK doc: Parsing Java with QDox

Perhaps you noticed recently that there’s a new interesting page on Groovy’s website ? Well, all pages are interesting of course! But there’s a new page describing the Groovy methods enhancing the core JDK classes. In groovy, you have additional methods that you can call on standard Java classes. For instance, you can use the eachLine() method on java.io.File. With this method, you’ll be able to easily read a text file line after line, and do whatever with this line inside a closure without having to care about things like closing streams. Read more...

CVS and SSH2, not so easy

Yesterday, I was granted commit rights on the Groovy source tree, at Codehaus. Of special interest for me : I developed a utility class which helps Groovy create new Readers for text files with the correct encoding already set (I’m really keen on charset/encodings issues), Adding some new Groovy methods to the core JDK classes, Working on an automatic documentation generation engine “a la” Javadoc, so that it may be possible to browse all the methods that have been added to the core JDK classes. Read more...

Groovy: a sample script

In the IntelliJ forums, I came across an off-topic (but funny) post by Robert Gibson who was wondering : Somebody told me once that there are only two words in the English language which contain each vowel, once only, in alphabetical order. Anybody know what the other one is? Indeed, there are more than two words corresponding to those constraints. I then wrote a little Java class which took all the words of a words file (with 100k words) and tested if they matched a regexp corresponding to those constraints. Read more...

LOAF : a Groovy implementation

LOAF is taking the community by storm. I do firmly believe it gonna rock the world. Social software is the way to go : the next revolution. But as far as I know there were no LOAF implementation in Groovy, a promising programming language. So let’s see how simple it is to write a LOAF implementation using Groovy: class LOAF { static main(args) { def loaf = new LOAF() } } I’m a beginner in Groovy, so use at your own risk. Read more...