Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
This page is about the XML-based module descriptor file which identifies and defines a Magnolia Maven module. If you are using a Magnolia light module, you should use a YAML-based module descriptor.
The XML file:
- Conforms to module.dtd.
- Is stored in
- Can refer to nodes of the module pom file.
When you start Magnolia, the system identifies available modules by locating each module's descriptor file.
Benefits of a module descriptor
The XML based module descriptor has a number of benefits:
- Dependency injection: Inject components into the module.
- Module version handling: Smoother version changes with Maven.
- Dependencies: Define runtime and install time dependencies to other modules.
- Servlets: Register servlets in your module.
- Workspaces: Create workspaces.
- Module class: Register a module class that allows you to define module specific properties.
Example module descriptor
Here is an example XML Maven module descriptor that defines a module class (
class element), a module version handler (
versionHandler element), an IoC component, and a dependency on the
Lines 8, 22: Note how you can refer to Maven properties within the module descriptor.
Module descriptor elements
The functional name of the module. You will see this name in the config workspace.
The module version.
The display name of the module.
Full description of the module.
The name of a module class.
The name of the version handler class.
Properties that can be used with the version handler.
Dependencies on other modules - the module will install only after the specified modules.
Servlets which will be included in the servlet filter.
The repositories which must exist or will be created for this module.
Injected components used by the module. Example: Defining an app or subapp as a component
For each module you have to provide:
groupIdto the identify the Maven artifact
- Name of the file.
<name>of the module in the file.
There are no strict naming conventions. You should give a name that reflects the purpose of the module. The name may also contain the name of your company.
Depending on the module purpose it might be a good idea to use the same value for the artifact ID and module name.
It is definitively good practice to name the module descriptor file by the pattern
- Module name: Social Media Hub
- Artifact ID:
- Group ID:
com.tinext.magnolia(contains the name of the creator Tinext.com)
- Module descriptor file:
where the version number consists of three parts:
x.y.z. In this notation
x.y denotes a major version and
z a maintenance release. The last two parts are optional. For a strict version dependency, use just one version string.
The VersionRange class supports the following notation to indicate version dependency.
Only three parts are supported. The major, minor and security version positions. The build number is not supported. See Runtime.Version for more information.
*- Includes all versions - When using this option in a YAML file, please wrap
*with quotes (
1.2- Matches only 1.2 exactly.
1.2/*- Matches all versions including and above 1.2.
1.2/1.2.9- Matches all versions including and between 1.2 and 1.2.9.
[1.2,1.2.9]- Inward square brackets mean inclusion. Same as above. Matches all versions including and between 1.2 and 1.2.9.
[1.2,1.2.9[- Outward square brackets mean exclusion. Matches all versions between 1.2 and 1.2.9, including 1.2 but excluding 1.2.9.
[1.2,1.2.9)- Parentheses mean exclusion. Same as outward square brackets above. Matches all versions between 1.2 and 1.2.9, including 1.2 but excluding 1.2.9.
Must have major version 3.
Must have major version 3.6.
Must have major version 3.6 and maintenance version 3.
Must have major version 3 or higher.
Must have major version 3.6 or higher.
Must have major version 3.6 and maintenance version 3 or higher.
Must have major version 3 or lower.
Must have major version 3.6 or lower.
Must have major version 3.6 and maintenance version 3 or lower.
Version not lower than 3.5 and not higher than 3.6.2.
|Versions between 3.5 and 3.6.2 including the boundaries.|
|Versions between 3.5 and 3.6.2, excluding the upper boundary 3.6.2.|
|Versions between 3.5 and 3.6.2, excluding the upper boundary 3.6.2. Same as above but alternative syntax.|
You can define runtime or install time dependencies (not build dependencies). If you define a dependency on a module, then this module will be installed and started before your module. A dependency can be optional. Optional in this context means that if an optional module is not present, installation will proceed, but if the optional module is present, this module will be installed first. The dependencies could look like this:
module-bwill be loaded before
module-a.The order becomes important, for example, if both
module-bdecorate the same definition or if
module-ainherits a definition from
Workspaces can be defined in the module descriptor. If necessary Magnolia initializes these workspaces before the installation starts. As an example look at the data module:
Under the hood, these repository workspaces are registered and initialized by the SetupModuleRepositoriesTask when the module is installed.