❯ Guillaume Laforge

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. Though there are still some bugs we haven’t fixed yet regarding “verify errors” and such, this snapshot is already much more stable. Next week, we should release a new distribution.

Read more...

Seen on maven IRC

Being a groovy despot, I was in the process of redeploying groovy’s web site and also the latest snapshot jars of the distribution which a lot of guys have asked for. But I was having some problems with my setup, ssh connection, maven goals, etc. With Trygve and Bob, we were chatting about that, and here is an interesting snippet of the ongoing discussion:

trygvis: bob: dist is a recursive symlink bob: yes, I know bob: it’s broken bob: I’ll fix it bob: and I’ll smack the next person who tells me about it trygvis: DO IT NOW! [Guillaume] LOL :-))) bob: FUCK YOU trygvis: OK!!

Read more...

IntelliJ : SSH2 finally finds its way...

I’ve been waiting for that for months already. I’ve been whining and whining again about the lack of an internal SSH2 implementation in IntelliJ. And now, it is there!

As you perhaps already know by reading my weblog, I’m a Groovy developper. And the Groovy project is hosted at Codehaus which makes use of SSH2 for accessing the CVS repository.

I had tried, but without success, different alternatives, such as using Putty/pling/pageant, but I didn’t manage to create a connection. So I ended up using Thomas Singer’s wonderful SmartCVS. This tools sort of saved my life. I’m very grateful to you Tom…

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.accept(Closure) which takes a closure argument which uses a socket as argument

What’s better than a sample code to illustrate that ? Hey, we’re going to implement a simplistic Hello World web server. Here it is…

Read more...

First steps in TDD-land

Unit tests aren’t really new for me, but so far, on the different projets on which I worked recently, I haven’t really had the opportunity to develop “test firt”. Moreover, I could not test much because those projects were not pretty test-friendly (static instances all around, nothing close to IoC/DI anywhere around). And also, on web-based and GUI projects, it is not that easy to write tests (when I have time, I should definitely have a look at those HTTP and Swing testing frameworks). Because of those projects, I was quite used to test things here and there with main methods and System.out.println()… you’ll agree with me that it’s not really professional. Not easy to make regression tests as well. Shame on me!

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.txt").getText("UTF-8") 

There is also a getText() method on Process which gathers the output of a process:

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.currentTimeMillis() - start
}

Then you can use your brand new timing closure:

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.

I wish a very happy birthday to Codehaus, and to all those who made it happen. Thank you Bob, and thank you James for Groovy ;-)

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. Let’s illustrate this with an example :

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.

James asked me if I wanted a CVS access to deal with those matters of interest instead of tunneling through him, and I gladfully accepted. But, alas, here starts the nightmare…

Read more...