Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: changes according to DOCU-1502

A Magnolia module can be purely be purely file based or it can be wrapped in a Maven project.

Table of Contents

Multiexcerpt
MultiExcerptNamestructure-comparison
Magnolia module wrapped in a typical Maven module
structure before it is built.
File-based Magnolia module under $magnolia.resources.dir
=
Light

...

module
Code Block
<maven-module-name>/
    ├── pom.xml
    └── src/
        └── main/
            ├── java/
            └── resources/
                ├── META-INF/
                │   └── magnolia/
                │       └── module-name.xml
                └── <module-name>/
                    ├── apps/
                    ├── dialogs/
                    │   └── myDialog.yaml
                    ├── webresources/
                    └── templates/
                        ├── components/
                        │   ├── myComponent.ftl
                        │   └── myComponent.yaml
                        └── pages/
                            ├── myTemplate.ftl
                            └── myTemplate.yaml
Code Block

...

  
  
 
  
  
  
  
   
   
$magnolia.resources.dir/
└── <module-name>/
    ├── apps/
    ├── dialogs/
    │   └── myDialog.yaml
    ├── module.yaml
    ├── webresources/
    └── templates/
        ├── components/
        │   ├── myComponent.ftl
        │   └── myComponent.yaml
        └── pages/
            ├── myTemplate.ftl
            └── myTemplate.yaml



Notes:

  • Include Page
    _What is magnolia.resources.dir
    _What is magnolia.resources.dir
  • <module-name> folder folder contains exactly the same content in a Maven module and folder-based module. In a Maven module this folder is within  is within src/main/resources  . In a folder-based modules this folder is within within $magnolia.resources.dir .Avoid spaces and special characters (ü, ä, ö) in <module-name>
  • Include Page
    INCL:_module_name allowed characters
    INCL:_module_name allowed characters

Info

Multiexcerpt include
MultiExcerptNamemodule_structure
PageWithExcerpt_CLI_PromotionBoxes

Module subfolders

apps

optional

Configuration data for apps (YAML files)

decorations

optional

Definition decorator files files (YAML files)

dialogs

optional

Dialogs (YAML files), may have subfolders

fieldTypes

optional

FieldType definitions (YAML files).

i18n

optional

i18n message bundle (.properties files).

messageViews

optional

MessageView definitions (YAML files).

webresources

optional

All the web resources, typically contains subfolders. (Folder name is arbitrary.)

templates

optional

Template definitions (YAML files) and scripts with subfolders

...

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 the $magnolia.resources.dir directory directory.

By default $magnolia.resources.dir is is the webapp folder, for instance magnoliaAuthor or magnoliaPublic. See See Add the module folder to $magnolia.home for more information about $magnolia.home.

Creating a light module with Magnolia CLI

Include Page
_Creating a light module with Magnolia CLI
_Creating a light module with Magnolia CLI

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 eases the process of creating a JAR file, deployment, and dependency management of your modules.  All 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 Maven archetype to build the skeleton of a Magnolia Maven module. The archetype provides options to build different modules:  

  • Basic Magnolia module
  • Theme module
  • Magnolia module to be hosted on the Magnolia Forge
  • Magnolia module using Blossom
  • Magnolia project (a parent pom and a webapp))

The archetypeCatalog is in https://nexus.magnolia-cms.com/content/groups/public/.

...

  1. Create a directory on your local file system where the project will be stored and change into this directory.
  2. Execute the following maven command:

    Code Block
    languagetext
    mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeCatalog=https://nexus.magnolia-cms.com/content/groups/public/ 

    Include Page
    INCL:_mvn archetype command
    INCL:_mvn archetype command

  3. Choose an archetype when prompted. Here we choose the option option magnolia-module-archetype which is a simple Magnolia project wrapped into Maven structure. Maven will then ask us for the standard Maven properties such as which version of Magnolia we will be using. 

  4. Next, the script asks to choose the archetype version - we recommend to choose always the latest version.

  5. Now you must prompt typical Maven properties such as groupIdartifactIdpackage name and version plus the Magnolia specific parameters magnolia-bundle-versionmodule-class-name and module-name.
    When you have prompted all the parameters - the archetype summarizes your inputs and you must confirm or can skip.

    Code Block
    languagetext
    Choose archetype: 1: https://nexus.magnolia-cms.com/content/groups/public/ -> info.magnolia.maven.archetypes:magnolia-theme-archetype (An archetype to create STK Theme modules) 2: https://nexus.magnolia-cms.com/content/groups/public/ -> info.magnolia.maven.archetypes:magnolia-project-archetype (An archetype to create a Magnolia project (a parent pom and a webapp)) 3: https://nexus.magnolia-cms.com/content/groups/public/ -> info.magnolia.maven.archetypes:magnolia-module-archetype (An archetype to create basic Magnolia modules) 4: https://nexus.magnolia-cms.com/content/groups/public/ -> info.magnolia.maven.archetypes:magnolia-forge-module-archetype (An archetype to create a Magnolia module to be hosted on the Magnolia Forge) 5: https://nexus.magnolia-cms.com/content/groups/public/ -> info.magnolia.maven.archetypes:magnolia-blossom-module-archetype (An archetype to create Magnolia modules using Blossom) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 3 Choose info.magnolia.maven.archetypes:magnolia-module-archetype version: 1: 1.1.0 2: 1.2.0 3: 1.2.1 4: 1.2.2 5: 1.2.3-SNAPSHOT Choose a number: 5:

    Code Block
    languagetext
    Define value for property 'groupId': : com.example
    Define value for property 'artifactId': : myModule
    Define value for property 'version':  1.0-SNAPSHOT: :
    Define value for property 'package':  com.example: :
    Define value for property 'magnolia-bundle-version': : 5.4.16
    Define value for property 'module-class-name': : MyModule
    Define value for property 'module-name':  myModule: :
    Confirm properties configuration:
    groupId: com.example
    artifactId: myModule
    version: 1.0-SNAPSHOT
    package: com.example
    magnolia-bundle-version: 5.4.16
    module-class-name: MyModule
    module-name: myModule
     Y: : Y

    If you confirm, Maven generates the archetype skeleton.