A Magnolia module can be purely file based or it can be wrapped in a Maven project.
|Magnolia module wrapped in a typical Maven module |
structure before it is built.
|File-based Magnolia module under $magnolia.resources.dir|
magnolia.resources.diris a property defining the directory from which resources are loaded in a Magnolia instance. This directory is used for file-based resources such as light modules and for overriding classpath resources. The property is configured in
WEB-INF/config/default/magnolia.propertiesand has the default value
$magnolia.home/modules. To see the current value of the property, go to the Config Info tab in the About Magnolia app.
You can use symbolic links (a.k.a symlinks or soft links) in the resources directory to include light modules located elsewhere on your system.
Set the property
magnolia.resources.filesystem.observation.excludedDirectoriesto exclude directories from being observed for changes. (See Configuration management - magnolia.resources.filesystem.observation.excludedDirectories.)
<module-name>folder contains exactly the same content in a Maven module and folder-based module. In a Maven module this folder is within
src/main/resources. In a folder-based modules this folder is within
When creating a name for a module, do not use spaces, accented characters such as
üor special characters such as slashes
\and so on. The name must match the regular expression
create-light-module command in the Magnolia CLI creates the module folder structure on the file system automatically.
Configuration data for apps (YAML files)
Definition decorator files (YAML files)
Dialogs (YAML files), may have subfolders
FieldType definitions (YAML files).
i18n message bundle (.properties files).
MessageView definitions (YAML files).
All the web resources, typically contains subfolders. (Folder name is arbitrary.)
Template definitions (YAML files) and scripts with subfolders
Folder-based module in $magnolia.resources.dir
Starting with Magnolia 5.4, a Magnolia module does not have to be a Maven module. You can add a file-based module in the
$magnolia.resources.dir is the webapp folder, for instance
magnoliaPublic. See Add the module folder to $magnolia.home for more information about
Creating a light module with Magnolia CLI
Using the Magnolia CLI you can create the folder structure for a light module with the command
create-light-module. Open a shell,
cd to your light modules directory, and execute the following command:
üor special characters (e.g. slashes
\and so on). The name must match the regular expression
Note that this only works if you have installed Magnolia CLI, see Magnolia CLI Installation.
Magnolia Maven module
If you are familiar with Java and Maven you may want to use Maven to create and build your Magnolia module. Using Maven eases the process of creating a JAR file, deployment, and dependency management of your modules. All modules provided by Magnolia are built with Maven. This makes it easy to install or uninstall them by adding or removing a JAR file.
Creating a Magnolia Maven module with Maven archetypes
Magnolia provides a set of Maven archetypes for various tasks, one of which is creating a Magnolia Maven module.
Before running the Maven
archetype command, please read How to use Magnolia Maven archetypes: Check Maven settings.
If you are not familiar with the Maven archetype plugin, please also read How to use Magnolia Maven archetypes: The archetype plugin.
Executing the archetype plugin command
Open a shell and change to the directory where you want the Magnolia Maven module skeleton to be created.
Run the following command:
Maven prompts you to specify values for several parameters. Use values that fit your requirements:
|Maven ||Typically reflects the name or domain of your company or projects.|
|Maven ||Project-specific identifier.|
|Maven artifact ||Project version. Typically, when creating a new project, use the value suggested by Maven, for example |
|Package name for Java classes reflecting both your company (or domain) and the specific project.|
Magnolia version from which your custom project inherits.
|The Java class name of the autogenerated module class.|
After you have finished entering the values, the archetype plugin displays their list and asks you to confirm it. If you confirm by pressing
ENTER , the plugin generates the skeleton of your archetype. You should see a
BUILD SUCCESS message at the end of the process. If you press
C, nothing is generated.
resources directories contain more subfolders. For further details, see above.