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