Fluent Commerce Logo
Docs
Sign In

Module Recipe - How to create an Extension Module

How-to Guide

Authors:

Marco Heuer, Matthew Hesford

Changed on:

25 Mar 2025

Key Points

  • Describe the steps to create a new module with a custom plugin
  • TL;DR from module creation to installation:
  • Create:
    `fluent module create`
  • Update
    `resources/module.json`
    with the module's version, dependencies and module name
  • Add in the source code + unit and integration tests under the
    `plugins/`
    folder

Steps

Step arrow right iconPrepare Extension Module

  • Change into the directory for the new module or create it
  • Create the new module by running
    `fluent module create -n <module-name>`

Step arrow right iconAdd the extension assets to the module

Next up is adding in the content.

First, update the version and any dependencies in

`resources/module.json`

Example: 

1{
2    "_schema": "1.0.0",
3    "name": "moduletest",
4    "version": "1.0.1",
5    "title": "Fluent Commerce - Module Template",
6    "authors": [
7        {
8            "name": "Fluent Commerce - Module Template",
9            "email": "labs@fluentcommerce.com",
10            "web": "https://fluentcommerce.com"
11        }
12    ],
13    "dependencies": [
14        {
15            "name": "fluent-commerce/core",
16            "type": "module",
17            "version": ">=1.0.0 <2.0.0"
18        }
19    ],
20    "contracts": []
21}

Language: sh

Name: module.json

Description:

Example module.json showing name and version updated

  • Copy the workflow and any other assets into the directory
    `resources`
  • Copy any source code in to the directory
    `plugin`

For example:

`plugins/rules/sample1/src/main/java/com/fluentcommerce/sample1 where "sample" is your plugin name so if this was a common plugin for the company "Acme" it would be plugins/rules/acme/src/main/java/com/fluentcommerce/acme/orders`

Rule source code files would go into:

`plugins/rules/sample1/src/main/java/com/fluentcommerce/sample1/`

 Model source code would go into:

`plugins/types/sample1/src/main/java/com/fluentcommerce/sample1/`

Any common, DTO, service and util source code would go into:

`plugins/util/sample1/src/main/java/com/fluentcommerce/sample1/common`

`plugins/util/sample1/src/main/java/com/fluentcommerce/sample1/dto`

`plugins/util/sample1/src/main/java/com/fluentcommerce/sample1/service`

`plugins/util/sample1/src/main/java/com/fluentcommerce/sample1/util`

Note: Rules are dependent on both type and util, Util is dependant on type

Step arrow right iconBuild the Extension Module

Now we're ready to build the extension module and create the Module Structure. Essentially this is a copy process, of the assets from the

`resources`
directory into a new
`dist`
directory. 

With modules that contain a plugin, this step includes compiling the rules, executing tests, creating the plugin.jar file and copying it over into the

`dist`
directory.

For convenience, the module template provides a build script in the

`scripts`
directory.

  • Execute
    `scripts/build_module.sh`
    - check out the options, for example
    `-x`
    to for verbose logging. As there is likely to be a plugin in this kind of module do not use option
    `-p`

Now the module is ready to be used. You can inspect it in the

`dist`
directory as either the Module Archive
`*.zip`
or the Module Structure in
`dist/<module-name>/`
.

Step arrow right iconInstall the Extension Module

Once the module has been built, it's time to deploy it or in module jargon, install it.

If the module or any of its assets requires configuration, like network refs or catalogue refs, then you need to create a config file first:

  • Perform a
    `fluent module config dist/<module-name>-<version>/`
    or
    `fluent module config dist/<module-name>-<version>.zip`
    and use the config file in the subsequent module install command
1fluent module config dist/moduletest-1.0.1/ --profile cli-b2c --retailer b2c

Language: plain_text

Name: Example Module Configuration

Description:

[Warning: empty required content area]

For full command parameters please see here.

Finally, install the module:

  • Run
    `fluent module install dist/<module-name>-<version>/`
     or
    `fluent module install dist/<module-name>-<version>.zip`

1fluent module install dist/moduletest-1.0.1/ --config module.config.b2c.moduletest.json --profile cli-b2c --retailer b2c

Language: plain_text

Name: Example Module Installation

Description:

[Warning: empty required content area]

For full command parameters please see here

Remember, you can install a module from its Module Structure or the Module Archive. The install command automatically unpacks an archive, if needed.

Marco Heuer

Marco Heuer

Contributors:
Matthew Hesford