Skip to main content

Setup Development Environment

This is the 1st article of the Build Java Module for Mango series. See the full series in the Module Development Overview.

This guide walks you through setting up your IDE and build tools so you can compile and install custom Mango modules.

Requirements

You need to have the latest stable version of JDK and Maven installed:

Project Setup

The first thing you need to do is configure your IDE to build Mango modules. This guide uses IntelliJ IDEA (community edition). Follow these steps:

  • Create a root directory to clone the repositories into. For example, create a radixIot directory.
  • Download the latest version of Mango (you can download it from the Mango Store). This Mango installation will help you test the module. You can place this directory wherever you want. Below, you will create a settings.xml file that points to this directory.
  • Clone the following repositories into the radixIot directory:
  • Create a pom.xml file in the radixIot directory with the following content:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.infiniteautomation.mango</groupId>
<artifactId>mango-root</artifactId>
<version>5.0.0-SNAPSHOT</version>
<name>Modules and core</name>
<packaging>pom</packaging>
<organization>
<name>Radix IoT</name>
<url>http://www.RadixIoT.com/</url>
</organization>
<modules>
<module>./ma-core-public</module>
<module>./ma-modules-public</module>
<module>./ma-dashboards</module>
</modules>
</project>

This file is helpful when you want to include modules located in different directories.

  • Open the pom.xml file as a Maven project from the IDE. This will load all the modules that you previously cloned.
  • Create a settings.xml file and set your Mango root directory (the path to the Mango installation you downloaded earlier):
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>set-ma-home</id>
<properties>
<MA_HOME>/{YOUR MANGO ROOT DIRECTORY}/mango</MA_HOME>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>set-ma-home</activeProfile>
</activeProfiles>
</settings>

Create the Module Project

  • Create an energyMetering directory inside your radixIot workspace.
  • Create a pom.xml file in the energyMetering directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>modules-parent</artifactId>
<groupId>com.infiniteautomation.mango</groupId>
<version>5.0.0-SNAPSHOT</version>
<relativePath>../ma-core-public/Modules/pom.xml</relativePath>
</parent>
<artifactId>EnergyMetering</artifactId>
<version>5.0.0-SNAPSHOT</version>
<name>EnergyMetering</name>
<build>
<plugins>
<plugin>
<groupId>eu.somatik.serviceloader-maven-plugin</groupId>
<artifactId>serviceloader-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<!-- <plugin>-->
<!-- <groupId>com.github.eirslett</groupId>-->
<!-- <artifactId>frontend-maven-plugin</artifactId>-->
<!-- </plugin>-->
</plugins>
</build>
<description>Energy Metering</description>
</project>

The module uses ma-core-public as the parent module. The frontend-maven-plugin is commented out for now and will be enabled when you add the frontend later in the series.

Build and Verify

  • In the IDE, right click on energyMetering/pom.xml and select Add as Maven project.
  • Go to Preferences > Build, Execution, Deployment > Build Tools > Maven and set the User settings file to the settings.xml file path you created.
  • Go to Run > Edit Configurations... and add a new Maven configuration with the goal install -Pinstall-module.

This configuration will build your module directly from the IDE. Click Run 'EnergyMetering', and a Run panel will open with the build process. If everything succeeds, you should see a BUILD SUCCESS message.

You should also see a EnergyMetering-5.0.0-SNAPSHOT.zip in <YOUR MANGO ROOT>/web/modules. There are many more things to configure before the module does anything useful, but your development platform is ready.

Continue to Module Configuration to set up the database tables and module metadata.