1 # Mograsim Development Environment
3 <span style="color:grey">_Mograsim Development Documentation Version 0.3 --- 2019-09-27_</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 - Short explanation of the different names and terms used in Eclipse Plugin Dev,
50 and short introduction to the different mechanisms used.
54 The tree of Mograsim projects:
56 - `plugins` - _This contains all bundles/plugins that provide functionality to Mograsim_
57 - **net.mograsim.logic.core** <br> The core logic for pure simulation. This contains
58 the most important low-level logic circuits and gates and defines how that
59 logic gets simulated. The underlying system for simulation in Mograsim is an
60 event based approach (see `Timeline`), using VHDL-like logic defined in `Bit`
61 and `BitVector`. More complex ciruits are build out of `Wire`s connecting `Component`s.
62 - **net.mograsim.logic.model** <br>The model describes how that core logic is
63 displayed and arranged, and allows (de-)serialization to JSON. The core logic
64 model gets generated based on this. Every basic net.mograsim.logic.core Component
65 has a model equivalent here that represents it in the GUI and persisted state
67 - **net.mograsim.logic.model.editor** <br> This bundle contains a standalone
68 SWT-based editor to edit Mograsim JSON-models in a comfortable way. It can
69 be used to create a new `SubmodelComponent` by arranging existing ones to a
70 new component. Note that editing and simulation are entirely different processes
71 in Mograsim, the editor cannot simulate and a running simulation cannot be
72 edited. (At least in the current state)
73 - **net.mograsim.logic.model.am2900** <br> This plugin contains a model for the
74 AMD Am2900 Family Microprocessors arranged into a microprogrammable model.
75 This can be used in the microprogram editor of the Mograsim plugin and in the
76 Mograsim assembler editor (by using a properly set up instruction set). We
77 took care that the plugin is independent, meaning that it only provides an
78 implementation for an extension point of the net.mograsim.machine plugin and
79 no other Mograsim depends on it.<br> This is also the way to go if you want
80 to add your own machine definitions to Mograsim and use them there.
81 - **net.mograsim.machine** <br> The machine plugin defines an extension point
82 that can be extended and implemented in other (your own) plugins to provide
83 new machines to Mograsim. In addition to the extension point and the most important
84 interfaces, it contains some commonly required or useful components to build/define
85 another machine. net.mograsim.logic.model.am2900 for example is such an extension.
86 The machine plugin itself scans for all available implementations of the interface
87 given by the extension point, and other parts of the Mograsim plugin get access
89 - **net.mograsim.plugin.core** <br> This is - as the name says - the core plugin
90 of mograsim. Here lie all the Eclipse Platform specific parts that make Mograsim
91 as an Eclipse plugin work. This includes the different editors, view, settings
92 and other functional extension to the Eclipse IDE.
93 - **net.mograsim.plugin.core.nl_de** <br> This optional plugin provides a German
94 localization for Mograsim.
95 - **net.mograsim.plugin.branding** <br> This contains elements for branding the
96 feature plugin, and additional resources and raw files (original logo and icon
97 in SVG and Adobe Illustrator and similar).
98 - **net.mograsim.plugin.docs** <br> The Plugin providing the user documentation.
99 - **net.mograsim.preferences** <br> A plugin for managing and accessing preferences.
100 - `features` - _This contains all Mograsim feature plugins_
101 - **net.mograsim.feature** <br> The Mograsim feature plugin, containing all the
102 plugins above and combining them into a feature. A feature is a plugin collection
103 with additional properties that allows for easy installation by the end user.
104 For this purpose, it also contains license information, authors, updatesite
105 location (allows eclipse to automatically check if updates are available) and
107 - `products` - _This contains standalone Mograsim product(s)_
108 - **net.mograsim.product** <br> A product can be pretty much anything (see Eclipse
109 RCP), in our case, this is simply a pre-configured Eclipse package, comparable
110 to the packages located at [www.eclipse.org/downloads/packages](https://www.eclipse.org/downloads/packages/).
111 - `releng` - _Abbreviation for **Rel**ease **Eng**ineering, contains important configuration_
112 - **net.mograsim.configuration** <br> This contains the configuration for the
113 Mograsim project and the build in particular. The central Maven configuration
114 is located here in a single `pom.xml`, that is the super-parent of all others,
115 including the generated ones.
116 - **net.mograsim.updatesite** <br> This updatesite project collects features
117 in form of an update site that can be accessed by Eclipse to install new features
118 or update features. The features are grouped into categories which can come
119 with further descriptions. The `target/repository/` is the part of the whole
120 Mograsim project that actually gets deployed. By using Help -> Install New
121 Software -> Add -> Local, the `repository`-folder can be selected and features
122 can be installed offline, e.g. to test them.
123 - **net.mograsim.target** <br> The target definition for the build. This is a
124 well-defined environment that we expect the plugins to work in/with. That includes
125 all plugin dependencies (like all plugins the Eclipse Platform is comprised
126 of) and the (minimum) JRE that is expected. Some plugins exclusively for testing
127 are included here, too.
128 - `tests` - _This contains (integration-like) tests in form of plugin fragments_
129 - **net.mograsim.logic.core.tests**
130 - **net.mograsim.logic.model.am2900.tests**
131 - **net.mograsim.machine.tests**
132 - `SWTHelper` - _This contains the [SWTHelper](https://github.com/Haspamelodica/SWTHelper)
134 - `bundles` - _This submodule folder needs to be named like that for Tycho pom-less
136 - **SWTInput** - Contains type specific input fields for SWT.
137 - **SWTObjectWrappers** - SWT object abstractions to enable zooming and optimizations.
138 - <span style="color:grey">_SWTSystemInOutApplication_</span> - _unused_
139 - <span style="color:grey">_SWTTiledZoomableCanvas_</span> - _unused_
140 - **SWTZoomableCanvas** - The SWT canvas we draw the simulation in.
144 Use the main aggregator `pom.xml` next to this markdown file to build mograsim, take
145 care to use the correct JDK to run it (see Run Configuration).
147 A short guide to the [Maven goals (Maven Lifecycle)](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html):
148 - The `clean` goal will remove all `target`-folders and other generated files like
149 flattened poms and polyglot build artifacts (all are listed in `.gitignore`).
150 - The `validate` goal is useful to simply check if the setup itself (Maven Tycho)
151 is ok and everything needed is available.
152 - The `integration-test` goal will run the test plugins, the `test` goal beforehand
154 - I recommend running `clean verify` or `verify`, this will do everything up to and
155 including the testing.
157 Please note that Tycho 1.5.0 is not released yet, and thus requires a workaround.
158 More information can be found under [Maven Core Extension Problems](#mceps).
162 Not everything is as simple as it seems at first glance.
164 ### Maven Core Extension Problems <a name="mceps"></a>
166 The Tycho extra `tycho-pomless` is a Maven core extension allows for simpler structure
167 and less redundancy. Maven core extensions must be available at [the central maven repository](http://repo.maven.apache.org/maven2/)
168 (or already in the local repository), you cannot specify an alternative remote repository
169 in `.mvn/extensions.xml`. If a core extension cannot be resolved, you will get currently
170 (Maven 3.6.2) only a warning like
172 > [WARNING] The POM for org.eclipse.tycho.extras:tycho-pomless:jar:1.5.0-SNAPSHOT is missing, no dependency information available
174 This means that the extension was not found, and it cannot be used, which leads to
175 a failure later on. To get around that, create a dummy pom that only serves the purpose
176 to "request" and resolve the extension:
179 <project .. bla .. bla ..>
180 <modelVersion>4.0.0</modelVersion>
181 <groupId>net.mograsim</groupId>
182 <artifactId>net.mograsim.tycho-download</artifactId>
183 <version>1.0.0</version>
184 <packaging>pom</packaging>
187 <!-- currently necessary because we are using a SNAPSHOT build of tycho -->
189 <id>tycho-snapshots</id>
190 <url>https://repo.eclipse.org/content/repositories/tycho-snapshots/</url>
192 <enabled>true</enabled>
195 <enabled>true</enabled>
196 <updatePolicy>always</updatePolicy>
199 </pluginRepositories>
204 <groupId>org.eclipse.tycho.extras</groupId>
205 <artifactId>tycho-pomless</artifactId>
206 <version>1.5.0-SNAPSHOT</version>
212 While that this is not the most compact way, it can be run by the developer and build
213 server equally easy and does not require special CLI knowledge. As developer, you
214 need to run that only once (in Eclipse: right click on pom.xml -> Run As -> Maven
215 clean). For continuous integration, you can insert one more line in the YAML (or
216 equivalent), like in our case ` - mvn $MAVEN_CLI_OPTS clean`.
220 Git submodules are a challenge with a tycho build, because the projects that reside
221 in it need to be build, too. But not only that, they need to use the same configuration
222 for the build, which is problematic if you do not have control over them. The solution
223 only exists with Tycho 1.5.0 (currently only as snapshot), where deep folder structures
224 are automatically scanned and poms get gnereated; not every folder requires an aggregator
225 pom. This however requires (at the moment) certain naming conventions (see section
228 In our case, [SWTHelper](https://github.com/Haspamelodica/SWTHelper) is a git submodule
229 containing several plain Java Eclipse projects with OSGi configuration (MANIFEST.MF),
230 which is the reason this works at all. Due to the naming conventions, the submodule
231 folder is named `bundles`.
233 ### Maven incompatibility
235 Maven 3.6.2 is currently incompatible with Tycho <= 1.5.0.
239 > [FATAL] Non-readable POM "somepath"\tests\.polyglot.pom.tycho: input contained no data @
243 > [FATAL] Non-readable POM "somepath"\bundles\net.mograsim.logic.core\.polyglot..META-INF_MANIFEST.MF: input contained no data @
245 make sure to use Maven 3.6.1 to fix that (this is the default Eclipse embedded Maven