Groovy Add-on » History » Revision 3
Revision 2 (Udo Offermann, 08.04.2013 12:10) → Revision 3/22 (Udo Offermann, 08.04.2013 15:52)
h1. Groovy Add-on The Groovy Add-on allows to use the "Groovy language":http://groovy.codehaus.org/ within z2 applications. It supports One can use pure Groovy modules beside pure Java modules as well as modules containing both Java and Groovy source code. The Groovy Add-on comes with latter case requires a three pass compilation (called "joint compilation mode") while in the Groovy version 2.1.2. h2. How does it work? first case all modules (Java and Groovy) are compiled within one single pass. The z2-Groovy compiler wrapper checks for each source component (i.e. @java/src.api@ and @java/src.impl@) whether it contains pure Groovy source files or Java and Groovy sources and chooses the appropriate compiler. The Joint-Compiler of Groovy SDK compiles mixed Groovy and Java sources within three passes: In step 1) all Groovy classes are compiled as stubs (i.e. only the signatures w/o any lines of code) so that in step 2) the Java compiler from the JDK can compile all Java classes and resolve all dependencies to Groovy classes using the stubs. In step 3) the Groovy source files are translated into bytecode - since the Java classes are now translated, references from Groovy to Java can be also resolved correctly. If however no Java sources are found step 1 and 2 are skipped and the compilation process is speed-up by leaving only the plain Groovy compiler! A mixture of Groovy classes and Java classes across z2 modules is supported as well. Since cyclic dependencies are not allowed this does not even require the Groovy Joint-Compiler. h2. How do I use it? Just put your Groovy source files into the same structure as Java source files - i.e. @<module-name>/java/src.api@, @<module-name>/java/src.impl@ or @<module-name>/java/src.test@. Edit the Java component descriptor and change/add the @java.compile.order@ property: @<module-name>/java/z.properties:@ <pre><code class="python"> com.zfabrik.component.type=com.zfabrik.java java.privateReferences=... java.publicReferences=... java.compile.order = groovy </code></pre> You might also change the heap and the perm size of the web worker since Groovy is usually much more hungry than plain Java. @environment/webWorker.properties:@ <pre><code class="python"> ... worker.process.vmOptions=\ -Xmx128m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -XX:MaxPermSize=256m \ ... </code></pre>