Module Recipe - Plugin Setup and Installation Guide
Author:
Nandha Balaguru
Changed on:
15 Mar 2025
Key Points
- Create the new module:
`fluent module create -n <module-name> `
- Populate the plugin structure in
`plugins/`
`rules/`
- Contains rules, unit tests and GraphQL queries/mutations
`types/`
- Stores model classes and extended DTOs
`util/`
- Holds service classes and utilities - Build the module:
`./scripts/build-module.sh`
- Install the module:
`fluent module install dist/<module-name>-<version>.zip -p <profile> -r <retailer>`
Prerequisites
Steps
Preparing the Custom Module
To create and initialize a new custom module, follow these steps:
- Navigate to the directory where the new module should be created.
- Run the following command to generate the module structure:
`fluent module create -m <module-name>`
Once the module is created, a plugins folder is also generated. It follows a multi-module Maven approach, ensuring a structured hierarchy for better maintainability and modularity of your rules and supporting services.
Understanding the Multi-Module Maven Structure
The `pom.xml`
file inside the `plugins`
folder contains all module dependencies and information. It typically includes:
`<modules>`
`<module>rules</module>`
`<module>types</module>`
`<module>util</module>`
`</modules>`
Recommended Directory Structure
Module | Purpose |
| Contains all the associated rules, unit tests and queries & mutations. |
| Contains all the model classes and extended DTO's. |
| Contains service classes and utility functions. |
This structured approach ensures modular development and better maintainability.
Building the Plugin and Module
- Navigate to the
`resources/`
directory and remove any unneeded asset directories. Retain the`module.json`
file since we are focusing on plugin installation.`Note : Plugins can be installed along with the data.`
- Edit the
`module.json`
file to add any other information about the module, eg author information or any module dependencies. - Execute
`./scripts/build-module.sh`
and build the module itself
Ensure that the build script is executed without the `-p`
option, otherwise it would skip the build step.
Once the build completes successfully, check the generated and inside the `dist/`
directory.
You can also inspect the assets in the module with `fluent module describe dist/<module-name>-<version>`
and confirm that the is present.
Installing the Module
To install the module, execute one of the following commands:`fluent module install dist/<module-name>-<version>/ --retailer <retailer> --profile <profile>`
or`fluent module install dist/<module-name>-<version>.zip --retailer <retailer> --profile <profile>`