Skip to content

ExportPluginTechnicalDocumentation

rubenanko edited this page Oct 14, 2026 · 1 revision

Export Plugin : Technical Documentation

Available features

The list of available features contains:

  • Exporting as a zip file
  • Exporting as a single file native executable using a self extracted archive (except for MacOS)
  • Include the user’s JDK to the export (optional)
  • Export one or more experiments
  • Export one or more models
  • Accessed data files through the file("../includes/building.shp") syntax are automatically included in the export if located outside of the GAMA project of the target models
  • GAMA linked files are handled
  • The exported application has an embedded workspace
  • If exported, user projects are copied in the embedded workspace
  • If exported, the projects from the model library are copied in the same path relative to the exported app
  • The exported app doesn’t update the workspace metadata
  • The exported app contains the minimal set of needed gama plugin for the exported plugin
  • Many interface elements are disabled in the simulation perspective of the exported application, as well as shortcuts.
  • Preferences configuration menus are completely removed in the exported application
  • In the exported app, simulation artifacts can be saved in the directory of choice

Launching a simulation

The entry point of the GAMA platform reads the flag SIMULATION_ONLY. If it is set to true, the class StartupModelHelper is instantiated.

The flags CORE_DEFAULT_MODEL and CORE_DEFAULT_EXPERIMENT are read to retrieve the default model and experiments stored in the preferences. If multiple experiments are detected, the instantiation triggers a selection menu by calling the method pickExperiment.

If experiments are from multiple models, the CORE_DEFAULT_MODEL flag is the empty string, and the string value of CORE_DEFAULT_EXPERIMENT has the following form :

first_experiment@/projectA/models/first_model.gaml#second_experiment@/projectB/models/second_model.gaml

These flags are defined in the preference file located in /configuration/.settings/gama.prefs, within the GAMA installation directory.

ExportActivator resolves the path of the active eclipse distribution, and resolves the project in the directory Embedded_Workspace/, by searching for .project files, and opens them to make sure they are registered in eclipse's resource system.

StartupModelHelper handles:

  • retrieval of the available models and experiments through the flags set by the preferences.
  • experiment selection/switching
  • model compiling
  • simulation launching

The same instance of StartupModelHelper is accessed throughout the program through a getInstance static method, allowing the class to hold data related to the available models and experiments.

Building an archive

User interfaces handling export configuration are calling the class GamaZipBuilder to create the exported application. GamaZipBuilder is the entry point of the export logic. Each export must be bound to a new instance. Every configuration option of the export is an argument passed to its constructor. The configuration happens in the class ExportProjectAsSimulation located in the plugin gama.ui.navigator.

GamaZipBuilder is :

  1. resolving the minimal set of needed plugins from the subset of plugins passed as constructor arguments (determined by the dynamic analysis), through static manifest based dependency analysis.

  2. Embedding GAMA’s app files in an archive file, and filtering useless plugins, and directories that are generated on startup (for example configuration/org.eclipse.osgi/ is not included)

  3. The file Gama.ini is edited to set the flags use_global_preference_store and simulation_only to true, and the argument persistState is set to false. If the zipWithJdk field is true, the correct “-vm ./jdk/bin/java” variant (depending on the target OS) is appended to the Gama.ini file.

  4. the following preferences are edited in the export : workspace_path, workspace_remember, startup_model, default_experiment, errors_in_editor, ask_rebuild and ask_outdated

  5. External data files dependencies are resolved

  6. The target project, and the projects containing models which are imported by the target models, are copied in the export’s embedded workspace, with, if needed, the external data files copied inside and their references updated.

  7. Resources referring to eclipse links instead of actual files are resolved and copied in the expected path in the export, by reading the .project metadata file of each included project.

  8. The .project metadata file is edited to remove the links.

  9. If the zipWithJdk field is true, the active jdk is resolved and copied in the export.

  10. If on MacOS, a troubleshoot.txt file containing instructions for disabling the gatekeeper is appended at the root of the archive. It’s a clever way of forcing MacOS to extract the content in a new folder having the same name as the archive, and which is recognized as an application.

  11. If the isOneFileExport field is true, a native executable working as a self extracting archive is created :
    a. If the OS is Linux, the archive is a zip file, and is concatenated to the files gama.plugin/export/binaries/runner and gama.plugin/export/binaries/zipextractor in such a way :
    beginning of the file → binaries/runner → binaries/zipextractor → archive.zip → end of the file
    Then the binaries/runner file is patched to update elf64 headers and custom metadata.

    b. If the OS is Windows, the archive is a 7z file and is appended to the file gama.plugin/export/binaries/7zS2.sfx is such a way :
    beginning of the file → binaries/7zS2.sfx → archive.zip → end of the file

The class BundleDependencyAnalyzer is in charge of the static manifest based dependency analysis, from the jar plugins.

The class ArchiveBuilder exposes high abstraction methods to manipulate zip or 7z archives seamlessly. This is important because if the isOneFileExport field is true, the archive must be a zip on Linux, and a 7z archive on Windows.

Building a single file executable

On Windows and Linux, a self extracting archive is built out of the archive made by GamaZipBuilder. It consists of a program to which is appended the archive, and which extracts the archive in a temporary directory before launching the entrypoint by itself.

On Windows, the solution from 7z is used, where appending a 7z archive to the 7zS2.sfx runner is enough, to extract the archive and automatically find the executable
https://7-zip.opensource.jp/chm/cmdline/switches/sfx.html

On Linux, the solution works the same, but is custom. The executable produced contains 3 components :

  • binaries/runner, the entrypoint of the program. It's written in assembly x64, assembled with nasm. Assembly allows the program to be smaller and reduces the amount of patching required after the concatenation with other components.
  • binaries/zipextractor, a small program for extracting the content of a zip archive, written in golang. Its only purpose is to be called by binaries/runner, because writing the unzip function in assembly would be unnecessarily difficult, and using libraries would complexify the layout of the executable file and memory.
     usage: zipextractor [-v] <source_file> <destination_dir>

The class ElfPacker is in charge of patching the native executable produced for Linux, by updating the elf64 headers to correct the new total size of the file, and fill a custom metadata table located at the end of gama.plugin/export/binaries/runner and containing 5 strings of 1024 bytes and 3 integers of 8 bytes.

These are appended to the file in the following order :

  • String 1 : path to the temporary directory where the zip archive will be extracted
  • String 2: path where zipextractor will be written on the file system
  • String 3: path where the archive payload will be written on the file system
  • String 4 : path where the content of the archive payload will be extracted
  • String 5 : path to the entrypoint of GAMA, in the tmp directory
  • Int 1 : zipextractor size
  • Int 2 : offset to archive in memory (also the zip extractor size)
  • Int 3 : size of the archive

binaries/runner :

  1. Creates the directory pointed by the path in String 1
  2. Writes the zipextractor on the file system at the path pointed by String 2
  3. Writes the archive on the file system at the path pointed by String 3
  4. calls the zipextractor with the correct argument to unzip the archive in the path pointed by String 4
  5. zipextractor does the actual archive extraction
  6. calls the entrypoint of GAMA pointed by String 5
  1. What's new (Changelog)
  2. Migration Guide (2025-06 → 2026-06)
  1. Installation and Launching
    1. Installation
    2. Launching GAMA
    3. Updating GAMA
    4. Installing Plugins
  2. Workspace, Projects and Models
    1. Navigating in the Workspace
    2. Changing Workspace
    3. Importing Models
  3. Editing Models
    1. GAML Editor (Generalities)
    2. GAML Editor Tools
    3. Validation of Models
  4. Running Experiments
    1. Launching Experiments
    2. Experiments User interface
    3. Controls of experiments
    4. Parameters view
    5. Inspectors and monitors
    6. Displays
    7. Batch Specific UI
    8. Errors View
  5. Running Headless
    1. Getting Started
    2. Headless Legacy
    3. Headless Batch
  6. Exporting Projects As Simulation Launchers
  7. Preferences
  8. Troubleshooting
  1. Introduction
    1. Start with GAML
    2. Organization of a Model
    3. Basic programming concepts in GAML
  2. Manipulate basic Species
  3. Global Species
    1. Regular Species
    2. Defining Actions and Behaviors
    3. Interaction between Agents
    4. Attaching Skills
    5. Inheritance
  4. Defining Advanced Species
    1. Grid Species
    2. Graph Species
    3. Mirror Species
    4. Multi-Level Architecture
  5. Defining GUI Experiment
    1. Defining Parameters
    2. Defining Displays Generalities
    3. Defining 3D Displays
    4. Defining Charts
    5. Defining Monitors and Inspectors
    6. Defining Export files
    7. Defining User Interaction
  6. Classes and Objects
    1. Class Definition and Instantiation
    2. Attributes and Actions
    3. Inheritance
    4. Virtual Classes
    5. Advanced Features
  7. Exploring Models
    1. Run Several Simulations
    2. Batch Experiments
    3. Exploration Methods
  8. Optimizing Models
    1. Runtime Concepts
    2. Analyzing code performance
    3. Optimizing Models
  9. Multi-Paradigm Modeling
    1. Control Architecture
    2. Defining Differential Equations
  1. Manipulate OSM Data
  2. Cleaning OSM Data
  3. Diffusion
  4. Using Database
  5. Using Dataframes
  6. Using FIPA ACL
  7. Using BDI with BEN
  8. Using Driving Skill
  9. Manipulate dates
  10. Manipulate lights
  11. Using comodel
  12. Save and restore Simulations
  13. Using network
  14. Writing Unit Tests
  15. Ensure model's reproducibility
  16. Going further with extensions
    1. Calling R
    2. Using Graphical Editor
    3. Using Git from GAMA
  1. Built-in Species
  2. Built-in Skills
  3. Built-in Architecture
  4. Statements
  5. Data Type
  6. File Type
  7. Stats Extension
  8. Sound Extension
  9. BDI Extension
  10. FIPA Skill
  11. Expressions
    1. Literals
    2. Units and Constants
    3. Pseudo Variables
    4. Variables And Attributes
    5. Operators (Definition)
    6. Operators [A-A]
    7. Operators [B-C]
    8. Operators [D-H]
    9. Operators [I-M]
    10. Operators [N-R]
    11. Operators [S-Z]
  12. Exhaustive list of GAMA Keywords
  1. Installing the development version
    1. Install GAMA source code with Eclipse plugin
  2. Developing Extensions
    1. Developing Plugins
    2. Developing Skills
    3. Developing Statements
    4. Developing Operators
    5. Developing Types
    6. Developing Species
    7. Developing Control Architectures
    8. Index of annotations
  3. Introduction to GAMA Java API
    1. Architecture of GAMA
    2. IScope
  4. Using GAMA flags
  5. Export plugin : Technical Documentation
  6. Creating a release of GAMA
  7. Documentation generation

  1. Predator Prey
  2. Road Traffic
  3. Incremental Model
  4. Luneray's flu
  5. BDI Agents
  6. Forager RL
  7. SIR Analysis
  8. 3D Model

  1. Team
  2. Projects using GAMA
  3. Scientific References
  4. Training Sessions

Resources

  1. Videos
  2. Conferences
  3. Pedagogical materials

Clone this wiki locally