1 # Mograsim Development Environment
3 <span style="color:grey">_Mograsim Development Documentation Version 0.4 --- 2019-10-17_</span>
5 A short guide to the Mograsim Maven Tycho configuration and Maven Tycho in general,
6 as well as some information on Eclipse Plugin Development and OSGi.
11 [Maven Tycho](https://www.eclipse.org/tycho/sitedocs/index.html) is a plugin for
12 [Maven](http://maven.apache.org) that allows building Eclipse and OSGi Projects comfortably
13 and automatically using Maven.
16 - [eclipse.org/tycho](https://www.eclipse.org/tycho/)
17 - [wiki.eclipse.org/Category:Tycho](https://wiki.eclipse.org/Category:Tycho)
18 - [vogella.com/tutorials/EclipseTycho](https://www.vogella.com/tutorials/EclipseTycho/article.html)
19 - [eclipse.org/tycho/sitedocs](https://www.eclipse.org/tycho/sitedocs/index.html)
20 - [Tycho pomless sources](https://git.eclipse.org/c/tycho/org.eclipse.tycho.extras.git/tree/tycho-pomless/src/main/java/org/eclipse/tycho/pomless)
21 (see *Mapping for naming and other conventions, TychoAggregatorMapping for folders)
25 OSGi is a module system for Java (completely unrelated to the Java 9 Jigsaw module
26 system) that allows detailed control over modules, dependencies, versions and more.
27 The file associated with OSGi here is a specific MANIFEST.MF in the META-INF directory
30 Roughly, an OSGi bundle has:
31 - a **symbolic name** that acts as an identifier, therefore it should be unique and
32 must not be changed, otherwise it a large portion of the configuration would break.
33 Never change that field after distribution.
34 - a **bundle name** and **bundle vendor**; this is only for the users and developers
35 and is not constrained in any way. You can change that, but it should be consistent
36 across all Mograsim modules. Both can be externalized to
37 - a **bundle version** that denotes current the version of the bundle. The `qualifier`
38 is replaced during the build process with a timestamp of the format `YYYYMMDDhhmmss`.
39 The version itself can be set using the maven tycho version plugin, which replaces
40 not only the maven versions, but all (equivalent) versions in the MANIFEST as well.
41 - a **bundle required execution environment** (abbr. BREE) where the bundle's *minimal*
42 JDK version is set. This is also the one eclipse uses and displays as JRE System
43 Library in the Eclipse projects.<br> This should be the same as the one the target
44 definition used for the build and the same that maven is run with ( -> check the
49 The tree of Mograsim projects:
51 - `plugins` - _This contains all bundles/plugins that provide functionality to Mograsim_
52 - **net.mograsim.logic.core** <br> The core logic for pure simulation. This contains
53 the most important low-level logic circuits and gates and defines how that
54 logic gets simulated. The underlying system for simulation in Mograsim is an
55 event based approach (see `Timeline`), using VHDL-like logic defined in `Bit`
56 and `BitVector`. More complex ciruits are build out of `Wire`s connecting `Component`s.
57 - **net.mograsim.logic.model** <br>The model describes how that core logic is
58 displayed and arranged, and allows (de-)serialization to JSON. The core logic
59 model gets generated based on this. Every basic net.mograsim.logic.core Component
60 has a model equivalent here that represents it in the GUI and persisted state
62 - **net.mograsim.logic.model.editor** <br> This bundle contains a standalone
63 SWT-based editor to edit Mograsim JSON-models in a comfortable way. It can
64 be used to create a new `SubmodelComponent` by arranging existing ones to a
65 new component. Note that editing and simulation are entirely different processes
66 in Mograsim, the editor cannot simulate and a running simulation cannot be
67 edited. (At least in the current state)
68 - **net.mograsim.logic.model.am2900** <br> This plugin contains a model for the
69 AMD Am2900 Family Microprocessors arranged into a microprogrammable model.
70 This can be used in the microprogram editor of the Mograsim plugin and in the
71 Mograsim assembler editor (by using a properly set up instruction set). We
72 took care that the plugin is independent, meaning that it only provides an
73 implementation for an extension point of the net.mograsim.machine plugin and
74 no other Mograsim depends on it.<br> This is also the way to go if you want
75 to add your own machine definitions to Mograsim and use them there.
76 - **net.mograsim.machine** <br> The machine plugin defines an extension point
77 that can be extended and implemented in other (your own) plugins to provide
78 new machines to Mograsim. In addition to the extension point and the most important
79 interfaces, it contains some commonly required or useful components to build/define
80 another machine. net.mograsim.logic.model.am2900 for example is such an extension.
81 The machine plugin itself scans for all available implementations of the interface
82 given by the extension point, and other parts of the Mograsim plugin get access
84 - **net.mograsim.plugin.core** <br> This is - as the name says - the core plugin
85 of mograsim. Here lie all the Eclipse Platform specific parts that make Mograsim
86 as an Eclipse plugin work. This includes the different editors, view, settings
87 and other functional extension to the Eclipse IDE.
88 - **net.mograsim.plugin.core.nl_de** <br> This optional plugin provides a German
89 localization for Mograsim.
90 - **net.mograsim.plugin.branding** <br> This contains elements for branding the
91 feature plugin, and additional resources and raw files (original logo and icon
92 in SVG and Adobe Illustrator and similar).
93 - **net.mograsim.plugin.docs** <br> The Plugin providing the user documentation.
94 - **net.mograsim.preferences** <br> A plugin for managing and accessing preferences.
95 - `features` - _This contains all Mograsim feature plugins_
96 - **net.mograsim.feature** <br> The Mograsim feature plugin, containing all the
97 plugins above and combining them into a feature. A feature is a plugin collection
98 with additional properties that allows for easy installation by the end user.
99 For this purpose, it also contains license information, authors, updatesite
100 location (allows eclipse to automatically check if updates are available) and
102 - `products` - _This contains standalone Mograsim product(s)_
103 - **net.mograsim.product** <br> A product can be pretty much anything (see Eclipse
104 RCP), in our case, this is simply a pre-configured Eclipse package, comparable
105 to the packages located at [www.eclipse.org/downloads/packages](https://www.eclipse.org/downloads/packages/).
106 - `releng` - _Abbreviation for **Rel**ease **Eng**ineering, contains important configuration_
107 - **net.mograsim.configuration** <br> This contains the configuration for the
108 Mograsim project and the build in particular. The central Maven configuration
109 is located here in a single `pom.xml`, that is the super-parent of all others,
110 including the generated ones.
111 - **net.mograsim.updatesite** <br> This updatesite project collects features
112 in form of an update site that can be accessed by Eclipse to install new features
113 or update features. The features are grouped into categories which can come
114 with further descriptions. The `target/repository/` is the part of the whole
115 Mograsim project that actually gets deployed. By using Help -> Install New
116 Software -> Add -> Local, the `repository`-folder can be selected and features
117 can be installed offline, e.g. to test them.
118 - **net.mograsim.target** <br> The target definition for the build. This is a
119 well-defined environment that we expect the plugins to work in/with. That includes
120 all plugin dependencies (like all plugins the Eclipse Platform is comprised
121 of) and the (minimum) JRE that is expected. Some plugins exclusively for testing
122 are included here, too.
123 - `tests` - _This contains (integration-like) tests in form of plugin fragments_
124 - **net.mograsim.logic.core.tests**
125 - **net.mograsim.logic.model.am2900.tests**
126 - **net.mograsim.machine.tests**
127 - `SWTHelper` - _This contains the [SWTHelper](https://github.com/Haspamelodica/SWTHelper)
129 - `bundles` - _This submodule folder needs to be named like that for Tycho pom-less
131 - **SWTInput** - Contains type specific input fields for SWT.
132 - **SWTObjectWrappers** - SWT object abstractions to enable zooming and optimizations.
133 - <span style="color:grey">_SWTSystemInOutApplication_</span> - _unused_
134 - <span style="color:grey">_SWTTiledZoomableCanvas_</span> - _unused_
135 - **SWTZoomableCanvas** - The SWT canvas we draw the simulation in.
139 Use the main aggregator `pom.xml` next to this markdown file to build mograsim, take
140 care to use the correct JDK to run it (see Run Configuration).
142 A short guide to the [Maven goals (Maven Lifecycle)](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html):
143 - The `clean` goal will remove all `target`-folders and other generated files like
144 flattened poms and polyglot build artifacts (all are listed in `.gitignore`).
145 - The `validate` goal is useful to simply check if the setup itself (Maven Tycho)
146 is ok and everything needed is available.
147 - The `integration-test` goal will run the test plugins, the `test` goal beforehand
149 - I recommend running `clean verify` or `verify`, this will do everything up to and
150 including the testing.
154 Not everything is as simple as it seems at first glance.
156 ### Maven Core Extension Problems
158 Context: Tycho 1.5.0 was not released, and thus required a workaround.
159 This Problem may appear again, maybe with a different core extension, so this section
160 explains the problem, how to diagnose it and a fairly good workaround.
162 The Tycho extra `tycho-pomless` is a Maven core extension allows for simpler structure
163 and less redundancy. Maven core extensions must be available at [the central maven repository](http://repo.maven.apache.org/maven2/)
164 (or already in the local repository), you cannot specify an alternative remote repository
165 in `.mvn/extensions.xml`. If a core extension cannot be resolved, you will get currently
166 (Maven 3.6.1) only a warning like
168 > [WARNING] The POM for org.eclipse.tycho.extras:tycho-pomless:jar:1.5.0-SNAPSHOT is missing, no dependency information available
170 This means that the extension was not found, and it cannot be used, which leads to
171 a failure later on. To get around that, create a dummy pom that only serves the purpose
172 to "request" and resolve the extension:
175 <project .. bla .. bla ..>
176 <modelVersion>4.0.0</modelVersion>
177 <groupId>net.mograsim</groupId>
178 <artifactId>net.mograsim.tycho-download</artifactId>
179 <version>1.0.0</version>
180 <packaging>pom</packaging>
183 <!-- currently necessary because we are using a SNAPSHOT build of tycho -->
185 <id>tycho-snapshots</id>
186 <url>https://repo.eclipse.org/content/repositories/tycho-snapshots/</url>
188 <enabled>true</enabled>
191 <enabled>true</enabled>
192 <updatePolicy>always</updatePolicy>
195 </pluginRepositories>
200 <groupId>org.eclipse.tycho.extras</groupId>
201 <artifactId>tycho-pomless</artifactId>
202 <version>1.5.0-SNAPSHOT</version>
208 While that this is not the most compact way, it can be run by the developer and build
209 server equally easy and does not require special CLI knowledge. As developer, you
210 need to run that only once (in Eclipse: right click on pom.xml -> Run As -> Maven
211 clean). For continuous integration, you can insert one more line in the YAML (or
212 equivalent), like in our case ` - mvn $MAVEN_CLI_OPTS clean`.
216 Git submodules are a challenge with a tycho build, because the projects that reside
217 in it need to be build, too. But not only that, they need to use the same configuration
218 for the build, which is problematic if you do not have control over them. The solution
219 only exists with Tycho 1.5.0 (currently only as snapshot), where deep folder structures
220 are automatically scanned and poms get gnereated; not every folder requires an aggregator
221 pom. This however **requires** (at the moment) certain naming conventions (see section
224 In our case, [SWTHelper](https://github.com/Haspamelodica/SWTHelper) is a git submodule
225 containing several plain Java Eclipse projects with OSGi configuration (MANIFEST.MF),
226 which is the reason this works at all. Due to the naming conventions, the submodule
227 folder is named `bundles`.
229 ### Maven incompatibility
231 Maven 3.6.2 is currently incompatible with Tycho <= 1.5.0.
235 > [FATAL] Non-readable POM "somepath"\tests\.polyglot.pom.tycho: input contained no data @
239 > [FATAL] Non-readable POM "somepath"\bundles\net.mograsim.logic.core\.polyglot..META-INF_MANIFEST.MF: input contained no data @
241 make sure to use Maven 3.6.1 to fix that (this is the default Eclipse embedded Maven