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:
- Azul Zulu JDK -- JDK 17+ runtime, JDK 25 for building
- Maven -- 3.9.9 or higher
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
radixIotdirectory. - 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.xmlfile that points to this directory. - Clone the following repositories into the
radixIotdirectory:ma-core-public-- GitHub: ma-core-public (Mango Automation Core public code)ma-dashboards-- GitHub: ma-dashboards (Core frontend code)ma-modules-public-- GitHub: ma-modules-public (Open source Mango modules)
- Create a
pom.xmlfile in theradixIotdirectory 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.xmlfile as a Maven project from the IDE. This will load all the modules that you previously cloned. - Create a
settings.xmlfile 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
energyMeteringdirectory inside yourradixIotworkspace. - Create a
pom.xmlfile in theenergyMeteringdirectory 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.xmland select Add as Maven project. - Go to Preferences > Build, Execution, Deployment > Build Tools > Maven and set the User settings file to the
settings.xmlfile 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.
Related Pages
- Custom Module Overview — Series roadmap and prerequisites
- Module Configuration — Next step: define database tables and module metadata
- Java Developer IDE Setup — Detailed IntelliJ IDEA setup for Mango 5.x modules