How to run a sample » History » Version 31
Udo Offermann, 21.05.2014 12:38
1 | 19 | Henning Blohm | h1. How to run a sample |
---|---|---|---|
2 | 1 | Henning Blohm | |
3 | Various z2-based sample system configurations have been prepared as Git repositories. |
||
4 | |||
5 | 23 | Henning Blohm | Assuming you know the repository URL these three steps (with or without Eclipse) are all there is to do. |
6 | 14 | Henning Blohm | |
7 | 25 | Henning Blohm | While these instructions are for Git users, they can be applied to the Subversion case quite similarly as described below. |
8 | |||
9 | 27 | Henning Blohm | *Note:* If you experience problems reaching out to the internet, you may need to configure some proxy settings. Please see [[How_to_proxy_settings]] for how that is done. |
10 | |||
11 | 31 | Udo Offermann | h1. Eclipse users |
12 | 14 | Henning Blohm | |
13 | 20 | Henning Blohm | Most likely you will want to look at code or configuration files of a sample. That is why we recommend to start from within the Eclipse IDE. If you prefer the command line or another IDE, please proceed to [[How to Run a Sample#From the command line|From the command line]]. |
14 | 14 | Henning Blohm | |
15 | 17 | Henning Blohm | Open Eclipse with a new workspace in a new folder, say *sample*. Note: We will clone repositories as siblings to your workspace. So let's assume your workspace is *sample/workspace*. |
16 | 1 | Henning Blohm | |
17 | 19 | Henning Blohm | h2. 1. Prepare a z2-base installation |
18 | 1 | Henning Blohm | |
19 | 17 | Henning Blohm | As the location where repositories are cloned to matters, it is simplest you open the Git tab in the Eclipse preferences and enter "${workspace_loc}/.." as default repository location. |
20 | 1 | Henning Blohm | |
21 | 18 | Henning Blohm | Open the Git Perspective and clone the "z2-base.core":http://redmine.z2-environment.net/projects/z2-base/repository/core repository from this URL *http://git.z2-environment.net/z2-base.core*. For convenience choose to import all projects into the workspace or do so after cloning has completed. You should end up having a project *core* in your workspace. That project is the z2 core that will fetch dependency resources as needed later on. |
22 | 1 | Henning Blohm | |
23 | 19 | Henning Blohm | h2. 2. Clone the sample repository |
24 | 17 | Henning Blohm | |
25 | Now repeat the same with the repository for the specific sample. It is important that the repository is cloned as a sibling to the core, So that the core can pick up modules defined in the sample. |
||
26 | |||
27 | 22 | Henning Blohm | h2. 3. Start and introspect |
28 | 1 | Henning Blohm | |
29 | You can launch Z2 from Eclipse by the _launcher_ file in the root of the *core* project (or by navigating to *Run* / *External Tools* / *External Tools Configurations...* and pick the launcher). A GUI wrapping the console should open up and you are ready to go. |
||
30 | 21 | Henning Blohm | |
31 | 1 | Henning Blohm | Once it is running, import the projects from the sample repository into your workspace, so that you can have a look at them. If you have previously installed the Eclipsoid plugin (see [[Step_3_-_First_steps_with_Z2_on_Git#Installation-of-the-Eclipsoid-plug-in]]) you can conveniently resolve all compilation dependencies with one click from within Eclipse. |
32 | 31 | Udo Offermann | |
33 | h1. Using IntelliJ |
||
34 | |||
35 | [[IntelliJ z2 plugin]] shows how to install the z2 plugin and its basic features. |
||
36 | You can checkout the z2 repositories from IntelliJ but make sure that you don't create a new project when IntelliJ asks you if "would you like to create a new IDEA project for ..."! |
||
37 | |||
38 | 17 | Henning Blohm | |
39 | 19 | Henning Blohm | h1. From the command line |
40 | 17 | Henning Blohm | |
41 | All you need is Java Runtime Environment (JRE) of at least version 6. Other pre-requisites, for example some database setup may be required based on the specific example, i.e. stuff that cannot be covered here. |
||
42 | 1 | Henning Blohm | |
43 | 19 | Henning Blohm | h2. 1. Prepare a z2-base installation |
44 | 2 | Henning Blohm | |
45 | Create a folder to hold the installation. We will assume that folder is called *sample* |
||
46 | |||
47 | In *sample* execute |
||
48 | 11 | Henning Blohm | |
49 | 5 | Henning Blohm | <pre> |
50 | 11 | Henning Blohm | git clone -b master http://git.z2-environment.net/z2-base.core |
51 | 2 | Henning Blohm | </pre> |
52 | |||
53 | Go into *sample/z2-base.core/run/bin* and run |
||
54 | |||
55 | <pre> |
||
56 | ./gui.sh |
||
57 | </pre> |
||
58 | |||
59 | or |
||
60 | |||
61 | <pre> |
||
62 | gui.bat |
||
63 | 1 | Henning Blohm | </pre> |
64 | 3 | Henning Blohm | |
65 | 2 | Henning Blohm | depending on your operating system. A simple graphical console should open up that displays the console log output of the z2 <home> and worker processes - as explained in http://www.z2-environment.eu/check_it_out. |
66 | |||
67 | 18 | Henning Blohm | At the first start, the environment will download required resources, which may take a few minutes - depending on your network bandwidth. Subsequent starts will be much quicker. Eventually the server should be up and you can go to the basic admin view at http://localhost:8080/adm (use z* with password z) to verify everything is cool. You do actually not need to start before completing step 3. But checking things are working doesn't hurt either. |
68 | 6 | Henning Blohm | |
69 | 1 | Henning Blohm | Stop the environment again by either pressing Ctrl+C on the console where you started the GUI or by clicking the Exit button on the GUI. |
70 | 3 | Henning Blohm | |
71 | 1 | Henning Blohm | h2. 2. Clone the specific sample repository |
72 | 3 | Henning Blohm | |
73 | 1 | Henning Blohm | Given the sample repository is called *z2-samples.sampleX*, go into *sample* once more and run |
74 | 3 | Henning Blohm | |
75 | 1 | Henning Blohm | <pre> |
76 | git clone -b master http://git.z2-environment.net/z2-samples.sampleX |
||
77 | 5 | Henning Blohm | </pre> |
78 | 3 | Henning Blohm | |
79 | 18 | Henning Blohm | h2. 3. Start |
80 | |||
81 | Now start the environment again as described above. The environment will now run with the sample configuration and all required dependencies. |
||
82 | 4 | Henning Blohm | |
83 | In other words: That's it. |
||
84 | 3 | Henning Blohm | |
85 | 19 | Henning Blohm | h2. Why does that actually work? |
86 | 3 | Henning Blohm | |
87 | If you care, here is how everything falls into place: |
||
88 | 13 | Henning Blohm | |
89 | 3 | Henning Blohm | The z2-base.core repository contains a z2 core installation that is bound to a remote "system repository" at "http://git.z2-environment.net/z2-base.base":http://redmine.z2-environment.net/projects/z2-base/repository/base?rev=master. As it is by now best practice with z2, that repository contains an *environment* module that describes system specific settings such as other repositories. |
90 | |||
91 | By cloning the sample repository you put an override of *environment* module into view of the _dev repository_. That is, the local server will take your local definitions with preference over the remote definitions. These may include other remote component repositories such as *z2-addons.spring*. |
||
92 | |||
93 | In addition the sample repository contains all the modules holding code and other resources that implement the actual sample. |
||
94 | |||
95 | If you already understand how the _dev repository_ works, you will not be surprised to find files called LOCAL in the module folders of cloned repository's workspace. |
||
96 | |||
97 | 24 | Henning Blohm | h2. Subversion support |
98 | |||
99 | 26 | Henning Blohm | Please see [[Repositories]] for the mapping of Git repositories to Subversion repositories. Samples are generally provided just the same - but throughout configured for Subversion - in the respective Subversion repositories. |
100 | 1 | Henning Blohm | |
101 | 26 | Henning Blohm | When you are using Eclipse, instead of cloning the whole repository to get the modules of the sample however, you do instead check out all modules in the repository to your workspace or in some folder. All the rest is just the same. |
102 | |||
103 | So, for example, given the z2-samples.spring-basic sample, from the command line run |
||
104 | |||
105 | <pre><code class="ruby"> |
||
106 | mkdir sample |
||
107 | cd sample |
||
108 | 28 | Udo Offermann | svn co --username=z2-envionment --password=z2-environment http://z2-environment.net/svn/z2-environment/trunk/z2-base.core |
109 | 29 | Udo Offermann | svn co --username=z2-envionment --password=z2-environment http://z2-environment.net/svn/z2-environment/trunk/z2-samples.spring-basic |
110 | 26 | Henning Blohm | cd z2-base.core/run/bin |
111 | ./gui.sh |
||
112 | </code></pre> |
||
113 | |||
114 | |||
115 | Similarly, in Eclipse, in some workspace, first check out http://z2-environment.net/svn/trunk/z2-base.core (should get your a project named "core") and then check out all projects underneath http://z2-environment.net/svn/trunk/z2-base.spring-basic. Use the z2 start launcher to start Z2. |
||
116 | 24 | Henning Blohm | |
117 | |||
118 | 3 | Henning Blohm | h2. References |
119 | |||
120 | 1 | Henning Blohm | * Dev Repository: http://www.z2-environment.eu/v20doc#Workspace%20Development%20Using%20the%20Dev%20Repository |