Page tree
Skip to end of metadata
Go to start of metadata

There instructions cover the steps for adding a custom module to an existing website project. 

Prerequisites

Create the module

When you have an existing Magnolia project (parent pom and webapp) you need to move inside the directory that contains your parent pom.

From the command line run:

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

Choose archetype:
1: An archetype to create STK Theme modules
2: An archetype to create a Magnolia project (a parent pom and a webapp)
3: An archetype to create basic Magnolia modules
4: An archetype to create a Magnolia module to be hosted on the Magnolia Forge
5: An archetype to create Magnolia modules using Blossom

Each archetype can have it's own set of versions.

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
6: 1.2.4-SNAPSHOT

Define the project:

groupIdcom.mycompany.templates
artifactIdmycompany-module-templates
version

5.6-SNAPSHOT

It can be helpful to align the project version with Magnolia version.

packagecom.mycompany.templates (press enter key to accept)
magnolia-version

5.6

The magnolia-version is equivalent to core version. This can be different than bundle-version.

module-class-nameMyCompanyTemplatesModule
module-name

mycompany-templates

This name will show up in the configuration tree. Avoid using the word "module" here because it's redundant.

Confirm success:

[INFO] project created from Archetype in dir: /Users/rgange/Temp/magnolia-cms/mycompany-module-templates
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] magnolia-cms (parent pom) .......................... SUCCESS [15:45 min]
[INFO] magnolia-cms: webapp ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15:46 min
[INFO] Finished at: 2018-04-24T11:04:35+02:00
[INFO] Final Memory: 16M/172M
[INFO] ------------------------------------------------------------------------

Tips

  • For every additional module added to the project you will find an entry in the parent pom.

    <modules>
      <module>magnolia-cms-webapp</module>
      <module>mycompany-module-templates</module>
    </modules>
  • There can be a discrepancy between bundle version and core version.
    • Check the info.magnolia.bundle.magnolia-bundle-parent pom for the magnoliaVersion, which ultimately determines the version of core.

      <properties>
        <magnoliaVersion>5.6</magnoliaVersion>
        <javaVersion>1.8</javaVersion>
      </properties>
  • Update your module pom so that it does not explicitly depend on a version of core. Or even remove it if you do not have a code dependency on core.

    By default the archetype creates a dependency on core with a specific version number.

    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-core</artifactId>
    </dependency>
  • Having a descriptor dependency on core is often not required.
    • There is already a transitive dependency.
    • The module does not make some configuration change to another module.
  • No labels