Run a simulation with Eclipse MOSAIC as Developer
On this page we want to discuss how to run Eclipse MOSAIC directly from source code, and with an IDE. This is only relevant if you want to implement changes to MOSAIC itself. If you simply want to run different simulations, please skip this page.
Prerequisites
You have to install the same requirements as for the bundeled MOSAIC version, namely the Java SDK and Eclipse SUMO. Additionally you also need to install Apache Maven.
Get the code
Please find the MOSAIC code in the GitHub repository here. Let’s say you would like to contribute your changes, so you fork the repository first, and read guideline how to contribute.
git clone git@github.com:<github-username>/mosaic.git eclipse-mosaic
cd eclipse-mosaic
git remote add upstream git@github.com:eclipse/mosaic.git # when using ssh
mvn clean install
From the Command-Line-Interface
The entry class MosaicStarter
has a lot of dependencies which need to be referenced during startup, so we recommend that you use the package functionality of maven and then run the bundle. Everything else would be overly complicated. Also, we don’t build “fat jars” so you won’t be able to run any jar directly. The following is almost the same procedure as presented in the non-developer guides, just that you build the bundle locally.
- Run
mvn clean install
- Unzip one of the
bundle/target/eclipse-mosaic-25.0-SNAPSHOT.zip/tar
archives to a destination of your choice - Run the
mosaic.sh/bat
files, which will do all the magic for you (have a look inside if you ask yourself if there’s a more direct way to start from console).
Use IntelliJ IDEA
- Start IntelliJ IDEA and choose
Open or Import
(see Figure 1). - Choose the cloned
eclipse-mosaic
repository - For IntelliJ there’s already a pre-defined run configuration in the repo which should work right away when you run it (see Figure 2).
Good to know:
- When changing any
pom.xml
you need to:Rightclick on root-module > Maven > Reload project
File locations
Given that you execute the code from source, some important file locations change:
Bundled | From Source |
---|---|
<mosaic-root>/scenarios |
<mosaic-root>/bundle/src/assembly/resources/scenarios |
<mosaic-root>/etc |
<mosaic-root>/rti/mosaic-starter/etc |
<mosaic-root>/logs |
<mosaic-root>/rti/mosaic-starter/logs |
Combine Mosaic (Windows IntelliJ IDE) with ns3 (WSL)
- In your WSL environment, download the
eclipse-mosaic-25.0-SNAPSHOT.zip/tar
and install ns-3 and federate ( usingns3_installer.sh
). - Copy the resulting
bin
folder (with the fully compiled ns3) into theeclipse-mosaic/rti/mosaic-starter
folder - Now it should behave as if you run everything from WSL