New Module development, getting started
-
So I have the basic build environment and have been playing around with the Serial Data Source as an example. Now I want to start working on my own module. How do I get this started? I assume the best may be to copy the Serial Data Source and rename it as a starting point, but then how do I get this new module brought into the build so it will build and become a part of Mango?
-
Hi Matt,
You are building on the Main branch, I believe, so all you'll need to do is copy the pom.xml from an existing module's base directory, edit the relevant fields (project name, version, dependencies), and you will be able to build it using the settings file like you would any other module.
Modules define their components by implementing classes found in the com.serotonin.m2m2.module package, here: https://github.com/infiniteautomation/ma-core-public/tree/main/Core/src/com/serotonin/m2m2/module
-
I guess I didn't ask it clearly enough, I get the part of editing the file but then what? For example, right now, if I run Mango, the only sources (modules) I can choose from are Serial Data Source, Virtual Data Source and Meta Data Source. Where do I put information to make other sources (modules) build into my Mango?
And I may as well go ahead and ask the follow-on question. How do I add BACnet to my build, as I suspect it is a bit more complex than the others?
-
The BACnet module's source is closed, so you cannot build that yourself. You downloaded the demo of the 3.0 core, so you can grab the BACnet module from 3.0/web/modules/BACnet, you can just move that into your git/ma-core-public/Core/web/modules and it will be loaded when you launch the core. That's where you got the Meta data source.
You will from build the pom.xml. Right click on it, run as a maven build. For the settings you need to link to the settings.xml file (which is in the other Maven builds you have defined for Virtual and Serial), the target is 'install' and the profile is 'install-module' (from the settings.xml file). This will create m2m2-YourModuleName-x.x.x.zip in git/ma-core-public/Core/web/modules which will be loaded when you launch Mango. Your module's 'loading' is done by checking which definitions classes (those in the com.serotonin.m2m2.module package) are extended in your module, and using them accordingly.