Sample-groovy-in-Z2 » History » Version 13
Henning Blohm, 28.04.2013 17:06
1 | 2 | Udo Offermann | h1. Sample Groovy in Z2 |
---|---|---|---|
2 | 3 | Udo Offermann | |
3 | 13 | Henning Blohm | This sample shows how to use the Groovy support, as implemented by the [[Groovy Add-on]]. |
4 | |||
5 | 3 | Udo Offermann | h2. Prerequisites |
6 | |||
7 | 12 | Henning Blohm | All you need is a JDK 6 or JDK 7 distribution as described in [[Step_2_-_Install_and_run_in_5_minutes]]. |
8 | 3 | Udo Offermann | |
9 | h2. Setting up the sample |
||
10 | |||
11 | There is no further pre-requisite to running this sample, and you may proceed as described in [[How to run a sample]]. Here's the really fast version: |
||
12 | |||
13 | <pre><code class="ruby"> |
||
14 | mkdir install |
||
15 | cd install |
||
16 | git clone -b master http://git.z2-environment.net/z2-base.core |
||
17 | git clone -b master http://git.z2-environment.net/z2-samples.groovy |
||
18 | |||
19 | # on Linux / Mac OS: |
||
20 | cd z2-base.core/run/bin |
||
21 | ./gui.sh |
||
22 | |||
23 | # on Windows: |
||
24 | cd z2-base.core\run\bin |
||
25 | gui.bat |
||
26 | </code></pre> |
||
27 | 4 | Udo Offermann | |
28 | The first time you launch the sample will take a while. Watch the log output and keep an eye out for the following lines: |
||
29 | <pre> |
||
30 | 7 | Udo Offermann | ...pp.WebAppResource [800]: Starting WebApp: com.zfabrik.samples.groovy.web/web |
31 | ...er.GroovyCompiler [800]: GROOVYC: Version 2.1.2 |
||
32 | ...er.GroovyCompiler [800]: GROOVYC: Compiling 'com.zfabrik.samples.groovy.web/java' using plain Groovy Compiler... |
||
33 | ...er.GroovyCompiler [800]: GROOVYC: 'com.zfabrik.samples.groovy.web/java' successfully compiled. |
||
34 | ...er.GroovyCompiler [800]: GROOVYC: Total 613ms |
||
35 | ...pp.WebAppResource [800]: Done starting Web App (/plain-groovy-sample): com.zfabrik.samples.groovy.web/web |
||
36 | ...pp.WebAppResource [800]: Starting WebApp: com.zfabrik.admin/web |
||
37 | ...pp.WebAppResource [800]: Done starting Web App (/adm): com.zfabrik.admin/web |
||
38 | ...pp.WebAppResource [800]: Starting WebApp: com.zfabrik.samples.groovy_and_java.web/web |
||
39 | ...er.GroovyCompiler [800]: GROOVYC: Version 2.1.2 |
||
40 | ...er.GroovyCompiler [800]: GROOVYC: Compiling 'com.zfabrik.samples.groovy_and_java.web/java' using Joint-Compiler... |
||
41 | ...er.GroovyCompiler [800]: GROOVYC: 'com.zfabrik.samples.groovy_and_java.web/java' successfully compiled. |
||
42 | ...er.GroovyCompiler [800]: GROOVYC: Total 608ms |
||
43 | ...pp.WebAppResource [800]: Done starting Web App (/groovy-java-sample): com.zfabrik.samples.groovy_and_java.web/web |
||
44 | </pre> |
||
45 | 4 | Udo Offermann | |
46 | If you want to inspect the code using Eclipse, please create a workspace in install (i.e. @install/workspace@) and import the Git repositories and the following projects into your workspace: _core_ from z2-base.core, _environemnt_ and _com.zfabrik.samples.groovy.web_ from z2-samples.groovy (see also [[Step_3_-_First_steps_with_Z2_on_Git|First steps]]). |
||
47 | 8 | Udo Offermann | |
48 | 10 | Udo Offermann | The sample apps just print the HTTP request header - the "first":http://localhost:8080/plain-groovy-sample is using plain Groovy (see project @com.zfabrik.samples.groovy.web@) and the "second":http://localhost:8080/groovy-java-sample/ is using a mixture of Groovy and Java sources (see project @com.zfabrik.samples.groovy_and_java.web@). Note that while the former project is compiled using the plain Groovy compiler the latter is compiled using the Joint Groovy/Java Compiler. |
49 | 11 | Udo Offermann | |
50 | Please refer to [[Groovy Add-on]] for more details and how-to use it for your own projects. |