It's been a while since I last posted news about Griffon. As you may recall back in January I hinted to some of the features that might be included in the upcoming 2.0.0 version. Today I'm happy to say that Griffon 2.0.0.BETA was released on June 8th, right after Gr8conf EU. Most of the features discussed back in January are now a reality; more so, you can try them out for yourself
The easiest way to get started is to leverage GVM to install Lazybones. Griffon 2.0.0 relies on Lazybones to provide project bootstrap templates given that the griffon
command line tool no longer exists. Installing GVM is as easy as invoking the following command
curl -s get.gvmtool.net | bash
Follow the instructions on your screen and you should get a working GVM installation. Next install the latest Lazybones release by invoking the following command
gvm install lazybones
We now have to tell Lazybones from where the Griffon project templates can be download. This is as easy as editing $USER_HOME/.lazybones/config.groovy and adding the following content
bintrayRepositories = [
"griffon/griffon-lazybones-templates",
"pledbrook/lazybones-templates"
]
OK, we're ready to create a simple Griffon project. Run the following command
lazybones create griffon-swing-groovy sample
Lazybones will graciously provided sensible defaults for all questions (such as package and versions) however you can pick any values that strike your fancy. Now comes the most interesting part, running the application. Switch into the sample
directory and run this command
./gradlew run
In a matter of seconds a window will pop up. Well done! Your first Griffon application is running in a matter of minutes and it didn't require a single line of code If you inspect the generated project sources you'll notice they're pretty much identical from Griffon 1.x, the main difference being that the project is now a full Gradle one, thus enabling you to do anything Gradle lets you do, for example, adding this project to a multi-project Gradle build and consuming sibling projects (say goodbye to the snapshots dependencies problem!). The Griffon team had to come up with all sort of ideas to part ways with the legacy build support inherited from Grails, embracing Gradle as a result. However a Griffon project does not strictly require Gradle as its sole built tool as there's no custom plugin for it (yet). All of the buildtime metadata is built using standard mechanisms such as Java's APT or Groovy's AST transformations. The Griffon compile support leverages both Jipsy and Gipsy to keep metadata files in sync.
Now if you happen to package the application and inspect its dependencies you'll find they amount to roughly 9M. That's a bit too much for this trivial application perhaps but not so for a standard desktop application. Bottom line is you get more bang for your buck as features start to pile up.
Size | Name |
---|---|
4467 | aopalliance-1.0.jar |
43033 | asm-3.1.jar |
278864 | cglib-2.2.1-v20090111.jar |
402075 | griffon-core-2.0.0.BETA.jar |
70114 | griffon-groovy-2.0.0.BETA.jar |
19135 | griffon-guice-2.0.0.BETA.jar |
111135 | griffon-swing-2.0.0.BETA.jar |
18558 | griffon-swing-groovy-2.0.0.BETA.jar |
7265222 | groovy-all-2.3.2.jar |
710492 | guice-3.0.jar |
2497 | javax.inject-1.jar |
31866 | jsr305-2.0.2.jar |
489884 | log4j-1.2.17.jar |
111002 | sample-0.1.0-SNAPSHOT.jar |
29257 | slf4j-api-1.7.7.jar |
8870 | slf4j-log4j12-1.7.7.jar |
However, what if you wanted to target a constrained environment, such as embedded device? Surely this memory footprint would play against you pretty soon. What if I tell you there's another way: a pure Java way.
lazybones create griffon-swing-java sample
Notice the change in the template name. This time the application will be initialized using Java as the main language. Change into the brand new sample
directory and inspect the code. It's Java code alright. Now run it as we did before
./gradlew run
Out comes a very similar popup. Packaging the application and looking at its dependencies results in huge decreaze in size: down to 2M!
Size | Name |
---|---|
4467 | aopalliance-1.0.jar |
43033 | asm-3.1.jar |
278864 | cglib-2.2.1-v20090111.jar |
402075 | griffon-core-2.0.0.BETA.jar |
19135 | griffon-guice-2.0.0.BETA.jar |
111135 | griffon-swing-2.0.0.BETA.jar |
710492 | guice-3.0.jar |
2497 | javax.inject-1.jar |
31866 | jsr305-2.0.2.jar |
489884 | log4j-1.2.17.jar |
87156 | sample-0.1.0-SNAPSHOT.jar |
29257 | slf4j-api-1.7.7.jar |
8870 | slf4j-log4j12-1.7.7.jar |
Sure, you don't have access to Groovy in this case but if you happen to run JDK8 then you gain access to Lambdas and more. Oh yes, Griffon's runtime API is JDK8 friendly; it'll gladly accept a lambda where a functional interface is expected.
There's a online version of the next Griffon Guide ready for your perusal. The team is quite pleased with the results so far however we encourage people to give us feedback on the new direction the framework has taken. Please take it for a spin and let us know, send us a message to the Griffon mailing list or tweet us at @theaviary.
Keep on Groovying!