Gradle plugin for FMI

I have published an Grade plugin for simplifying programmatic interaction with FMUs. The plugin is powered by FMI4j, which is compatible with FMI 2.0 for Co-simulation and Model Exchange.

Among other things, the plugin generates type safe getter and setters for all FMU variables – grouped by causality.
It also generates javadoc based on the information found in the modelDescription.xml.

FmiSimulation instance = ControlledTemperature.newInstance();

instance.init(); //throws on error

//Variables are grouped by causality and have types!
RealVariable tempRef = instance.getOutputs().temperature_Reference();

double stop = 10.0;
double stepSize = 1E-2;
while (instance.getSimulationTime() <= stop) {

  if (!instance.doStep(stepSize)) {

  FmuRead<Double> read =;
  System.out.println( + "=" + read.getValue());



To add it to your project, simply add the following code to your build.gradle

plugins {
  id "no.mechatronics.sfi.fmi4j.FmuPlugin" version "0.4.1"

The plugin will automatically add the required FMI4j dependency to your project.

One thought on “Gradle plugin for FMI

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.