The final restructured version for automatic build using maven tycho
[Mograsim.git] / MAVEN-TYCHO-README.html
1 <html><head>
2                 <meta charset='utf-8'>
3                 <meta http-equiv='x-ua-compatible' content='IE=edge'/>
4                 <meta name="viewport" content="width=device-width,initial-scale=1.0">
5                 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
6                 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
7                 <script>hljs.initHighlightingOnLoad();</script>
8 <style media="screen" type="text/css">
9 h1,h2,h3,h4,h5,h6{margin:20px 0 10px;padding:0;font-weight:700}code,tt{margin:0;padding:0;white-space:nowrap;border:1px solid #eaeaea;background-color:#f8f8f8;border-radius:3px}body{font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:1.6;color:#333;background-color:#fff;padding:20px;max-width:960px;margin:0 auto}body>:first-child{margin-top:0!important}body>:last-child{margin-bottom:0!important}body>h2:first-child{margin-top:0;padding-top:0}body>h1:first-child{margin-top:0;padding-top:0}body>h1:first-child+h2{margin-top:0;padding-top:0}body>h3:first-child{margin-top:0;padding-top:0}body>h4:first-child{margin-top:0;padding-top:0}body>h5:first-child{margin-top:0;padding-top:0}body>h6:first-child{margin-top:0;padding-top:0}p{margin:15px 0}blockquote{margin:15px 0;border-left:4px solid #ddd;padding:0 15px;color:#777}blockquote>:first-child{margin-top:0}blockquote>:last-child{margin-bottom:0}ul{margin:15px 0;padding-left:30px}ul li>:first-child{margin-top:0}ul li ul:first-of-type{margin-top:0}ul li ol:first-of-type{margin-top:0}ul ul{margin-bottom:0}ul ol{margin-bottom:0}ol{margin:15px 0;padding-left:30px}ol li>:first-child{margin-top:0}ol li ol:first-of-type{margin-top:0}ol li ul:first-of-type{margin-top:0}ol ol{margin-bottom:0}ol ul{margin-bottom:0}dl{margin:15px 0;padding:0}dl dt{font-size:14px;font-weight:700;font-style:italic;padding:0;margin:15px 0 5px}dl dt:first-child{padding:0}dl dt>:first-child{margin-top:0}dl dt>:last-child{margin-bottom:0}dl dd{margin:0 0 15px;padding:0 15px}dl dd>:first-child{margin-top:0}dl dd>:last-child{margin-bottom:0}table{margin:15px 0}table th{font-weight:700;border:1px solid #ccc;padding:6px 13px}table td{border:1px solid #ccc;padding:6px 13px}table tr{border-top:1px solid #ccc;background-color:#fff}table tr:nth-child(2n){background-color:#f8f8f8}pre{margin:15px 0;font-size:12px;font-family:Consolas,Liberation Mono,Courier,monospace;background-color:#f8f8f8;border:1px solid #ccc;font-size:13px;line-height:19px;overflow:auto;padding:6px 10px;border-radius:3px}pre>code{margin:0;padding:0;white-space:pre;border:none;background:0 0}pre code{background-color:transparent;border:none}pre tt{background-color:transparent;border:none}h1{font-size:28px;color:#000}h1 tt{font-size:inherit}h1 code{font-size:inherit}h1+p{margin-top:10px}h2{font-size:24px;border-bottom:1px solid #ccc;color:#000}h2 tt{font-size:inherit}h2 code{font-size:inherit}h2+p{margin-top:10px}h3{font-size:18px}h3 tt{font-size:inherit}h3 code{font-size:inherit}h3+p{margin-top:10px}h4{font-size:16px}h4 tt{font-size:inherit}h4 code{font-size:inherit}h4+p{margin-top:10px}h5{font-size:14px}h5 tt{font-size:inherit}h5 code{font-size:inherit}h5+p{margin-top:10px}h6{color:#777;font-size:14px}h6 tt{font-size:inherit}h6 code{font-size:inherit}h6+p{margin-top:10px}a{color:#4183c4;text-decoration:none}a:first-child h1{margin-top:0;padding-top:0}a:first-child h2{margin-top:0;padding-top:0}a:first-child h3{margin-top:0;padding-top:0}a:first-child h4{margin-top:0;padding-top:0}a:first-child h5{margin-top:0;padding-top:0}a:first-child h6{margin-top:0;padding-top:0}a:hover{text-decoration:underline}code{font-size:12px;font-family:Consolas,Liberation Mono,Courier,monospace}tt{font-size:12px;font-family:Consolas,Liberation Mono,Courier,monospace}kbd{background-color:#ddd;background-image:-webkit-gradient(linear,left top,left bottom,from(#f1f1f1),to(#ddd));background-image:linear-gradient(#f1f1f1,#ddd);background-repeat:repeat-x;border-color:#ddd #ccc #ccc #ddd;-o-border-image:none;border-image:none;border-radius:2px 2px 2px 2px;border-style:solid;border-width:1px;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;line-height:10px;padding:1px 4px}hr{clear:both;margin:15px 0;height:0;overflow:hidden;border:none;background:0 0;border-bottom:4px solid #ddd;padding:0}img{max-width:100%}
10 </style>
11 </head><body>
12 <h1>Mograsim Development Environment</h1>
13 <p><span style="color:grey"><em>Mograsim Development Documentation Version 0.1 &mdash; 2019-09-13</em></span></p>
14 <p>A short guide to the Mograsim Maven Tycho configuration and Maven Tycho in general,
15 as well as some information on Eclipse Plugin Development and OSGi.</p>
16 <h2>Maven Tycho</h2>
17 <p><a href="https://www.eclipse.org/tycho/sitedocs/index.html">Maven Tycho</a> is a plugin for
18 <a href="http://maven.apache.org">Maven</a> that allows building Eclipse and OSGi Projects comfortably
19 and automatically using Maven.</p>
20 <p>Useful links:</p>
21 <ul>
22 <li><a href="https://www.eclipse.org/tycho/">eclipse.org/tycho</a></li>
23 <li><a href="https://wiki.eclipse.org/Category:Tycho">wiki.eclipse.org/Category:Tycho</a></li>
24 <li><a href="https://www.vogella.com/tutorials/EclipseTycho/article.html">vogella.com/tutorials/EclipseTycho</a></li>
25 <li><a href="https://www.eclipse.org/tycho/sitedocs/index.html">eclipse.org/tycho/sitedocs</a></li>
26 <li><a href="https://git.eclipse.org/c/tycho/org.eclipse.tycho.extras.git/tree/tycho-pomless/src/main/java/org/eclipse/tycho/pomless">Tycho pomless sources</a>
27 (see *Mapping for naming and other conventions, TychoAggregatorMapping for folders)</li>
28 </ul>
29 <h2>OSGi</h2>
30 <p>OSGi is a module system for Java (completely unrelated to the Java 9 Jigsaw module
31 system) that allows detailed control over modules, dependencies, versions and more.
32 The file associated with OSGi here is a specific MANIFEST.MF in the META-INF directory
33 of each project.</p>
34 <p>Roughly, an OSGi bundle has:</p>
35 <ul>
36 <li>a <strong>symbolic name</strong> that acts as an identifier, therefore it should be unique and
37 must not be changed, otherwise it a large portion of the configuration would break.
38 Never change that field after distribution.</li>
39 <li>a <strong>bundle name</strong> and <strong>bundle vendor</strong>; this is only for the users and developers
40 and is not constrained in any way. You can change that, but it should be consistent
41 across all Mograsim modules. Both can be externalized to</li>
42 <li>a <strong>bundle version</strong> that denotes current the version of the bundle. The <code>qualifier</code>
43 is replaced during the build process with a timestamp of the format <code>YYYYMMDDhhmmss</code>.
44 The version itself can be set using the maven tycho version plugin, which replaces
45 not only the maven versions, but all (equivalent) versions in the MANIFEST as well.</li>
46 <li>a <strong>bundle required execution environment</strong> (abbr. BREE) where the bundle's <em>minimal</em>
47 JDK version is set. This is also the one eclipse uses and displays as JRE System
48 Library in the Eclipse projects.<br> This should be the same as the one the target
49 definition used for the build and the same that maven is run with ( -> check the
50 Run Configuration)</li>
51 </ul>
52 <h2>Eclipse Plugins</h2>
53 <ul>
54 <li>Short explanation of the different names and terms used in Eclipse Plugin Dev,
55 and short introduction to the different mechanisms used.</li>
56 </ul>
57 <h2>Mograsim Structure</h2>
58 <p>The tree of Mograsim projects:</p>
59 <ul>
60 <li><code>bundles</code> - <em>This contains all bundles/plugins that provide functionality to Mograsim</em><ul>
61 <li><code>extenal/swthelper</code> - <em>This contains the <a href="https://github.com/Haspamelodica/SWTHelper">SWTHelper</a>
62 git submodule.</em><ul>
63 <li><code>bundles</code> - <em>This submodule folder needs to be named like that for Tycho
64 pom-less build to work.</em><ul>
65 <li><span style="color:grey"><em>SWTInput</em></span> - <em>unused</em></li>
66 <li><strong>SWTObjectWrappers</strong> - SWT object abstractions to enable zooming and
67 optimizations.</li>
68 <li><span style="color:grey"><em>SWTSystemInOutApplication</em></span> - <em>unused</em></li>
69 <li><span style="color:grey"><em>SWTTiledZoomableCanvas</em></span> - <em>unused</em></li>
70 <li><strong>SWTZoomableCanvas</strong> - The SWT canvas we draw the simulation in.</li>
71 </ul>
72 </li>
73 </ul>
74 </li>
75 <li><strong>net.mograsim.logic.core</strong> <br> The core logic for pure simulation. This contains
76 the most important low-level logic circuits and gates and defines how that
77 logic gets simulated. The underlying system for simulation in Mograsim is an
78 event based approach (see <code>Timeline</code>), using VHDL-like logic defined in <code>Bit</code>
79 and <code>BitVector</code>. More complex ciruits are build out of <code>Wire</code>s connecting <code>Component</code>s.</li>
80 <li><strong>net.mograsim.logic.model</strong> <br>The model describes how that core logic is
81 displayed and arranged, and allows (de-)serialization to JSON. The core logic
82 model gets generated based on this. Every basic net.mograsim.logic.core Component
83 has a model equivalent here that represents it in the GUI and persisted state
84 (JSON).</li>
85 <li><strong>net.mograsim.logic.model.editor</strong> <br> This bundle contains a standalone
86 SWT-based editor to edit Mograsim JSON-models in a comfortable way. It can
87 be used to create a new <code>SubmodelComponent</code> by arranging existing ones to a
88 new component. Note that editing and simulation are entirely different processes
89 in Mograsim, the editor cannot simulate and a running simulation cannot be
90 edited. (At least in the current state)</li>
91 <li><strong>net.mograsim.logic.model.am2900</strong> <br> This plugin contains a model for the
92 AMD Am2900 Family Microprocessors arranged into a microprogrammable model.
93 This can be used in the microprogram editor of the Mograsim plugin and in the
94 Mograsim assembler editor (by using a properly set up instruction set). We
95 took care that the plugin is independent, meaning that it only provides an
96 implementation for an extension point of the net.mograsim.machine plugin and
97 no other Mograsim depends on it.<br> This is also the way to go if you want
98 to add your own machine definitions to Mograsim and use them there.</li>
99 <li><strong>net.mograsim.machine</strong> <br> The machine plugin defines an extension point
100 that can be extended and implemented in other (your own) plugins to provide
101 new machines to Mograsim. In addition to the extension point and the most important
102 interfaces, it contains some commonly required or useful components to build/define
103 another machine. net.mograsim.logic.model.am2900 for example is such an extension.
104 The machine plugin itself scans for all available implementations of the interface
105 given by the extension point, and other parts of the Mograsim plugin get access
106 to them that way.</li>
107 <li><strong>net.mograsim.plugin.core</strong> <br> This is - as the name says - the core plugin
108 of mograsim. Here lie all the Eclipse Platform specific parts that make Mograsim
109 as an Eclipse plugin work. This includes the different editors, view, settings
110 and other functional extension to the Eclipse IDE.</li>
111 <li><strong>net.mograsim.plugin.core.nl_de</strong> <br> This optional plugin provides a German
112 localization for Mograsim.</li>
113 <li><strong>net.mograsim.plugin.branding</strong> <br> This contains elements for branding the
114 feature plugin, and additional resources and raw files (original logo and icon
115 in SVG and Adobe Illustrator and similar).</li>
116 <li><strong>net.mograsim.plugin.docs</strong> <br> The Plugin providing the user documentation.</li>
117 <li><strong>net.mograsim.preferences</strong> <br> A plugin for managing and accessing preferences.</li>
118 </ul>
119 </li>
120 <li><code>features</code> - <em>This contains all Mograsim feature plugins</em><ul>
121 <li><strong>net.mograsim.feature</strong> <br> The Mograsim feature plugin, containing all the
122 plugins above and combining them into a feature. A feature is a plugin collection
123 with additional properties that allows for easy installation by the end user.
124 For this purpose, it also contains license information, authors, updatesite
125 location (allows eclipse to automatically check if updates are available) and
126 more.</li>
127 </ul>
128 </li>
129 <li><code>products</code> - <em>This contains standalone Mograsim product(s)</em><ul>
130 <li><strong>net.mograsim.product</strong> <br> A product can be pretty much anything (see Eclipse
131 RCP), in our case, this is simply a pre-configured Eclipse package, comparable
132 to the packages located at <a href="https://www.eclipse.org/downloads/packages/">www.eclipse.org/downloads/packages</a>.</li>
133 </ul>
134 </li>
135 <li><code>releng</code> - <em>Abbreviation for <strong>Rel</strong>ease <strong>Eng</strong>ineering, contains important configuration</em><ul>
136 <li><strong>net.mograsim.configuration</strong> <br> This contains the configuration for the
137 Mograsim project and the build in particular. The central Maven configuration
138 is located here in a single <code>pom.xml</code>, that is the super-parent of all others,
139 including the generated ones.</li>
140 <li><strong>net.mograsim.updatesite</strong> <br> This updatesite project collects features
141 in form of an update site that can be accessed by Eclipse to install new features
142 or update features. The features are grouped into categories which can come
143 with further descriptions. The <code>target/repository/</code> is the part of the whole
144 Mograsim project that actually gets deployed. By using Help -> Install New
145 Software -> Add -> Local, the <code>repository</code>-folder can be selected and features
146 can be installed offline, e.g. to test them.</li>
147 <li><strong>net.mograsim.target</strong> <br> The target definition for the build. This is a
148 well-defined environment that we expect the plugins to work in/with. That includes
149 all plugin dependencies (like all plugins the Eclipse Platform is comprised
150 of) and the (minimum) JRE that is expected. Some plugins exclusively for testing
151 are included here, too.</li>
152 </ul>
153 </li>
154 <li><code>tests</code> - <em>This contains (integration-like) tests in form of plugin fragments</em><ul>
155 <li><strong>net.mograsim.logic.tests</strong></li>
156 <li><strong>net.mograsim.logic.model.am2900.tests</strong></li>
157 <li><strong>net.mograsim.machine.tests</strong></li>
158 </ul>
159 </li>
160 </ul>
161 <h2>Build Mograsim</h2>
162 <p>Use the main aggregator <code>pom.xml</code> next to this markdown file to build mograsim, take
163 care to use the correct JDK to run it (see Run Configuration).</p>
164 <p>A short guide to the <a href="https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">Maven goals (Maven Lifecycle)</a>:</p>
165 <ul>
166 <li>The <code>clean</code> goal will remove all <code>target</code>-folders and other generated files like
167 flattened poms and polyglot build artifacts (all are listed in <code>.gitignore</code>).</li>
168 <li>The <code>validate</code> goal is useful to simply check if the setup itself (Maven Tycho)
169 is ok and everything needed is available.</li>
170 <li>The <code>integration-test</code> goal will run the test plugins, the <code>test</code> goal beforehand
171 <strong>will not.</strong></li>
172 <li>I recommend running <code>clean verify</code> or <code>verify</code>, this will do everything up to and
173 including the testing.</li>
174 </ul>
175 <p>Please note that Tycho 1.5.0 is not released yet, and thus requires a workaround.
176 More information can be found under <a href="#mceps">Maven Core Extension Problems</a>.</p>
177 <h2>Challenges</h2>
178 <p>Not everything is as simple as it seems at first glance.</p>
179 <h3>Maven Core Extension Problems <a name="mceps"></a></h3>
180 <p>The Tycho extra <code>tycho-pomless</code> is a Maven core extension allows for simpler structure
181 and less redundancy. Maven core extensions must be available at <a href="http://repo.maven.apache.org/maven2/">the central maven repository</a>
182 (or already in the local repository), you cannot specify an alternative remote repository
183 in <code>.mvn/extensions.xml</code>. If a core extension cannot be resolved, you will get currently
184 (Maven 3.6.2) only a warning like</p>
185 <blockquote><p>[WARNING] The POM for org.eclipse.tycho.extras:tycho-pomless:jar:1.5.0-SNAPSHOT is missing, no dependency information available</p>
186 </blockquote>
187 <p>This means that the extension was not found, and it cannot be used, which leads to
188 a failure later on. To get around that, create a dummy pom that only serves the purpose
189 to &ldquo;request&rdquo; and resolve the extension:</p>
190 <pre><code>&lt;project .. bla .. bla ..&gt;
191     &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
192     &lt;groupId&gt;net.mograsim&lt;/groupId&gt;
193     &lt;artifactId&gt;net.mograsim.tycho-download&lt;/artifactId&gt;
194     &lt;version&gt;1.0.0&lt;/version&gt;
195     &lt;packaging&gt;pom&lt;/packaging&gt;
196
197     &lt;pluginRepositories&gt;
198         &lt;!-- currently necessary because we are using a SNAPSHOT build of tycho --&gt;
199         &lt;pluginRepository&gt;
200             &lt;id&gt;tycho-snapshots&lt;/id&gt;
201             &lt;url&gt;https://repo.eclipse.org/content/repositories/tycho-snapshots/&lt;/url&gt;
202             &lt;releases&gt;
203                 &lt;enabled&gt;true&lt;/enabled&gt;
204             &lt;/releases&gt;
205             &lt;snapshots&gt;
206                 &lt;enabled&gt;true&lt;/enabled&gt;
207                 &lt;updatePolicy&gt;always&lt;/updatePolicy&gt;
208             &lt;/snapshots&gt;
209         &lt;/pluginRepository&gt;
210     &lt;/pluginRepositories&gt;
211
212     &lt;build&gt;
213         &lt;extensions&gt;
214             &lt;extension&gt;
215                 &lt;groupId&gt;org.eclipse.tycho.extras&lt;/groupId&gt;
216                 &lt;artifactId&gt;tycho-pomless&lt;/artifactId&gt;
217                 &lt;version&gt;1.5.0-SNAPSHOT&lt;/version&gt;
218             &lt;/extension&gt;
219         &lt;/extensions&gt;
220     &lt;/build&gt;
221 &lt;/project&gt;
222 </code></pre>
223 <p>While that this is not the most compact way, it can be run by the developer and build
224 server equally easy and does not require special CLI knowledge. As developer, you
225 need to run that only once (in Eclipse: right click on pom.xml -> Run As -> Maven
226 clean). For continuous integration, you can insert one more line in the YAML (or
227 equivalent), like in our case <code>- mvn  $MAVEN_CLI_OPTS clean</code>.</p>
228 <h3>Git Submodules</h3>
229 <p>Git submodules are a challenge with a tycho build, because the projects that reside
230 in it need to be build, too. But not only that, they need to use the same configuration
231 for the build, which is problematic if you do not have control over them. The solution
232 only exists with Tycho 1.5.0 (currently only as snapshot), where deep folder structures
233 are automatically scanned and poms get gnereated; not every folder requires an aggregator
234 pom. This however requires (at the moment) certain naming conventions (see section
235 on Tycho itself).</p>
236 <p>In our case, <a href="https://github.com/Haspamelodica/SWTHelper">SWTHelper</a> is a git submodule
237 containing several plain Java Eclipse projects with OSGi configuration (MANIFEST.MF),
238 which is the reason this works at all. Due to the naming conventions, the submodule
239 folder is named <code>bundles</code>.</p>
240 <h3>Maven incompatibility</h3>
241 <p>Maven 3.6.2 is currently incompatible with Tycho &lt;= 1.5.0.</p>
242 <p>If you encounter</p>
243 <blockquote><p>[FATAL] Non-readable POM &ldquo;somepath&rdquo;\tests.polyglot.pom.tycho: input contained no data @</p>
244 </blockquote>
245 <p>or</p>
246 <blockquote><p>[FATAL] Non-readable POM &ldquo;somepath&rdquo;\bundles\net.mograsim.logic.core.polyglot..META-INF_MANIFEST.MF: input contained no data @</p>
247 </blockquote>
248 <p>make sure to use Maven 3.6.1 to fix that (this is the default Eclipse embedded Maven
249 at the moment).</p>
250
251 </body></html>