-
Notifications
You must be signed in to change notification settings - Fork 8
Getting Started
Should you develop your own application and use 'MoDeS3 as a Service'.
-
Install Java 8 SDK.
-
Download the corresponding jar on the releases page.
-
Read the Wiki pages, especially Network messages, On the communication component of the API.
Should you be a core developer of the MoDeS3 repository and extend its core functionality.
root java folder = src/java
from the highest folder hierarchy
💡
|
Should you have any problems during compiling the repository, visit the Troubleshooting section of this document. |
Prerequisites:
-
Install Java 8 SDK.
-
Install Gradle (4.2.1) and have
gradle.exe
(Windows) orgradle
(Linux / Unix) on your OS path. -
Clone the BME-MODES3 repository on your machine.
-
Obtain an Eclipse with Gradle, Xtend, Xtext, Viatra and E(fx)clipse installed.
-
The version numbers of the currently used gradle plugins can be found here.
-
-
Set the default file encoding for UTF-8. In Eclipse do the following:
Window → Preferences → General → Workspace : Text file encoding
-
Run Gradle from command line in order to generate Java message definitions from protobuf. First go to the
root java folder
, then generate the Java classes:
cd src/java
./gradlew :messaging:hu.bme.mit.inf.modes3.messaging.proto.messages:generateProto
-
Import the Gradle projects in your IDE and try to build the projects there. Note: Should you not need a project, please put a comment mark
#
in front of the line for the corresponding project, in theroot java folder’s `build.gradle
file. Please do not commit these changes though.
A fat jar
is a jar which contains the compiled project along with every dependency the project has.
-
If you would like to create a fat jar from a certain component, add
apply plugin: 'com.github.johnrengelman.shadow'
to the respective components’sbuild.gradle
file.-
Then go to the
root java folder
and run the respective project’sshadowJar
task. -
The result fat jar will be created in the respective project’s
build/libs
folder and its default name will be the<project’s name>-all.jar
.
-
-
As an example, let’s see how to generate the fatJar of
hu.bme.mit.inf.modes3.messaging.communication
project:
cd src/java
./gradlew :messaging:hu.bme.mit.inf.modes3.messaging.communication:shadowJar
-
The fat jar will be in the
src/java/messaging/communication/build/libs
folder and its name will behu.bme.mit.inf.modes3.messaging.communication-all.jar
-
For more info on the
shadow
gradle plugin, check its repository.
-
Install
Ansible
on your machine.
-
If you would like to create deployable zips for each component, then go to the
root java folder
andassemble
the repository with gradle:
cd src/java
./gradlew assemble
-
The generated zip and tar files will be in each project’s
build/distributions/
folder, if the respective project is an application (seeapply plugin: 'application'
line inbuild.gradle
in the project’s folder). If it is not an application, then thebuild/libs/
folder will contain a jar compiled from the project sources. -
The generated archives should be extracted, then the component can be run by the executable file in the extracted
bin
folder. Please note that on Windows you should use the executable which ends with.bat
, on Linux or Unix machines use the one without.bat
ending. Also note that the command-line parameters should be the same as if it was a jar. So that the parameters the runnable expects should be fulfilled.-
e.g. if we’re in the extracted
hu.bme.mit.inf.modes3.components.occupancyquery
folder and its executable expects-address root.modes3.intra -port 1883 -serial /dev/ttyUSB0
parameters, then thebin/hu.bme.mit.inf.modes3.components.occupancyquery
file should be run as follows:
-
bin/hu.bme.mit.inf.modes3.components.occupancyquery -address root.modes3.intra -port 1883 -serial /dev/ttyUSB0
-
As an alternative method to the previous section, one could use the ansible scripts which are implemented in the
config-management/ansible
folder. Note that there are helper shell scripts for Linux/Unix deployment in theconfig-management
folder.
-
Projects using Xtend often need cleaning to remove obsolete error markers.
-
A project which depends on VIATRA may have an error saying "Error executing EValidator". This has no effect basically, simply get rid of the error by deleting the markers.
-
Should you use Eclipse with the Gradle plugin AND change something in any of the *.gradle files (either in the root
/src/java
folder or in your project’s folder), do not forget to click on theproject name with the right mouse button → Gradle → Plugin refresh
. Otherwise, the plugin might not recognize the changes and will end up in an incorrect configuration. -
Should you use VIATRA in Eclipse in any project, do not forget to set the folder into which VIATRA generates the Java classes. To do so go to
Window → Preferences → VIATRA → Query Language → Compiler
and set theOutput Folder / Directory
for./src/main/vql-gen
. After that, set that folder as a source folder of the project and exclude it from the .gitignore file in the project folder: write!/src/main/vql-gen/*
in the .gitignore file. However, this last step might be unnecessary if there is a VIATRA compiler available as a gradle plugin. (As of writing these lines, it is done available yet.) -
Should you have
Error executing EValidator in Viatra project
problems with buildinghu.bme.mit.inf.modes3.components.safetylogic.systemlevel.patterns
in Eclipse, check if thePlug-in project
,VIATRA
natures are added to the project:right click on project name → Configure → Convert to Plug-in Project (or Convert to VIATRA project)
-
Should you have build problems in Eclipse with Xtend, check if there is a
build/xtend/main
andbuild/xtend/test
folders in the project. If so, remove the folders. In addition to that, remove the<classpathentry kind="src" path="build/xtend/main"/> <classpathentry kind="src" path="build/xtend/test"/>
lines from the.classpath
file in the corresponding project. -
Never combine Xtend and pure Java files in the same source folder, because the Xtend / Xtext Compiler’s Gradle plugin will get crazy and either end up in a stack overflow exception or show error markers at references for java classes in xtend files.
-
Should some change notifications from the file system not arrive to Eclipse, don’t forget to use the 'good old' right click on the
project name → Refresh project
option. Restarting Eclipse might also solve problems sometimes. -
It also helps with already resolved errors and they are still in the
Problems View
, to do aProject / Clean
andProject / Build All
in Eclipse. -
Should you configure Eclipse for using Java JDK library instead of JRE. For doing this, open the corresponding project’s properties and in the
Java Build Path / Libraries
tab add or edit the defaultSystem Library’s Execution environment
for JavaSE-1.8 (jdk1.8).
👍
|
This page could not have been created without ecsedigergo |