/
README.html
167 lines (149 loc) · 7.51 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>EclipseCon 2012 Tycho Tutorial - Exercise 5</title>
</head>
<body>
<p align="center">
<a href="../../Exercise_04_Add_P2_Repository/tychodemo.parent/README.html"><Previous Exercise</a>
| <a href="../../../README.html">TOC</a>
<!-- | <a href="../../Exercise_06_Use_Target_File/tychodemo.parent/README.html">Next Exercise></a> -->
</p>
<h2>Exercise 5: Add a product</h2>
In this exercise, we build an installation of our RCP application and pack it into a ready-to-use ZIP archive.
<br />Offering an archive for download is a common way to distribute RCP applications.
<h3>Recovery option</h3>
This section is optional and only needed if you want to catch up from exercise 4 or reset your workspace.
<ul>
<li>Select <tt>File > Switch Workspace > Other...</tt> and choose folder <a href="../">Exercise_05_Add_Product</a></li>
<li>Import all five projects from this folder into the workspace using <tt>File > Import > Existing Maven Projects</tt></li>
<li>Trigger a build on the parent POM: <ul>
<li>Right-click on <tt>tychodemo.parent > Run As > Maven</tt></li>
<li>If an launch configuration dialog appears, enter the goals <tt>clean install</tt> and hit <tt>Run</tt></li>
</ul></li>
<li>The build should succeed and build five modules <pre>
tychodemo.parent
tychodemo.bundle
tychodemo.bundle.tests
tychodemo.feature
tychodemo.repository</pre>
</li>
</ul>
<h3>Building a product configuration file</h3>
<ol>
<li>Move the existing <tt>tychodemo.bundle.product</tt> file from the project <tt>tychodemo.bundle</tt> to the project <tt>tychodemo.repository</tt>
<br /><img src="../resources/product_move.png" />
</li>
<li>Configure the start levels and auto-start settings of the product: <ul>
<li>Open the <tt>tychodemo.bundle.product</tt> product definition</li>
<li>Switch to the <tt>Configuration</tt> tab</li>
<li>In the <tt>Start Levels</tt> section, click on <tt>Add...</tt>
<br /><img src="../resources/start_levels_add.png" />
</li>
<li>Select the bundles <tt>org.eclipse.equinox.common</tt> and <tt>org.eclipse.equinox.ds</tt> and hit <tt>OK</tt>
<br /><img src="../resources/start_levels_add_equinox.png" />
</li>
<li>For both bundles, set the start level to <tt>2</tt> and auto-start to <tt>true</tt></li>
<li>Click <tt>Add...</tt> again and add the bundle <tt>org.eclipse.core.runtime</tt></li>
<li>For <tt>org.eclipse.core.runtime</tt> only set auto-start to <tt>true</tt>
<br /><img src="../resources/start_levels.png" />
</li>
</ul></li>
<li>Enter the ID <tt>tychodemo.product</tt> on the <tt>Overview</tt> tab</li>
<li>Change the product definition to be based on features:
<br />(Background: Tycho <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=374947">bug 374947</a> makes it hard to build bundle-based products with platform-specific fragments.)
<ul>
<li>Select "The product configuration is based on <tt>features</tt>"
<br /><img src="../resources/feature_based.png" />
</li>
<li>On the <tt>Dependencies</tt> tab, click on <tt>Add...</tt> and select the <tt>tychodemo.feature</tt>, and hit <tt>OK</tt></li>
<li>In the same way, add the features <tt>org.eclipse.rcp</tt> and <tt>org.eclipse.e4.rcp</tt>
<br /><img src="../resources/feature_add_rcp.png" />
</li>
<li>
Click on <tt>Add Required</tt>; this also adds the two required EMF features
<br /><img src="../resources/feature_add_required.png" />
</li>
<li>Next, check that product configuration is consistent by clicking on the <tt>Validate...</tt> icon in the upper right corner of the editor
<br />The expected result is a missing requirement from our <tt>tychodemo.bundle</tt> to <tt>org.eclipse.core.resources</tt>
<br /><img src="../resources/core_resources_missing.png" />
</li>
<li>The bundle <tt>org.eclipse.core.resources</tt> is not needed in this example, so open <tt>tychodemo.bundle/META-INF/MANIFEST.MF</tt> and remove it from the list of required plug-ins
<br /><img src="../resources/core_resources_removal.png" />
</li>
<li>Now the product configuration is consistent and can be launched from the <tt>Overview</tt> tab of the product editor</li>
</ul>
</li>
<li>Run the build of <tt>tychodemo.parent</tt>, e.g. by right-clicking on <tt>tychodemo.parent > Run As > Maven build</tt>
<br />Expected results: <ul>
<li><tt>BUILD SUCCESS</tt></li>
<li>The p2 repository in <tt>tychodemo.repository/target/repository</tt> now contains the product metadata and the content of the product:
<br /><img src="../resources/product_published.png" />
</li>
</ul>
</li>
<li>Configure the build to create a product installation and archive <ul>
<li>Open the file <tt>tychodemo.repository/pom.xml</tt></li>
<li>Switch to the <tt>pom.xml</tt> tab and add the following snippet: <pre>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<!-- install the product using the p2 director -->
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
<execution>
<!-- create zip file with the installed product -->
<id>archive-products</id>
<goals>
<goal>archive-products</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</pre>
</li>
</ul></li>
<li>Run the build of <tt>tychodemo.parent</tt> again, e.g. by selecting <tt>tychodemo.parent</tt> from the run history
<br />Expected results: <ul>
<li><tt>BUILD SUCCESS</tt></li>
<li>There is now an installed product under <tt>tychodemo.repository/target/products/tychodemo.product/<os>/<ws>/<arch>/</tt>
<br /> <img src="../resources/product_materialized.png" />
</li>
</ul>
</li>
<li>Run the product executable
<br />Expected result: The <tt>tychodemo.bundle</tt> RCP is started, but the toolbar icons are missing
<br /><img src="../resources/rcp_noicons.png" />
</li>
<li>Configure the build to include the icons in the <tt>tychodemo.bundle</tt> JAR file: <ul>
<li>Open the file <tt>tychodemo.bundle/build.properties</tt></li>
<li>In the <tt>Binary Build</tt> section, select the <tt>icons</tt> folder
<br /><img src="../resources/add_icons.png" />
</li>
</ul></li>
<li>Close the RCP (if it is still running), run the build of <tt>tychodemo.parent</tt>, and launch the RCP again from the <tt>target</tt> folder of <tt>tychodemo.repository</tt> project
<br />Now the icons should be shown correctly
<br /><img src="../resources/rcp.png" />
</li>
</ol>
<br />
<p>
Congratulations! You have now completed the EclipseCon Tycho tutorial.
</p>
<p align="center">
<a href="../../Exercise_04_Add_P2_Repository/tychodemo.parent/README.html"><Previous Exercise</a>
| <a href="../../../README.html">TOC</a>
<!-- | <a href="../../Exercise_06_Use_Target_File/tychodemo.parent/README.html">Next Exercise></a> -->
</p>
</body>
</html>