This tutorial page explains how you can create a full-featured DX Core Magnolia webapp from a Magnolia Maven archetype. If you'd like to try creating a minimalistic webapp, see Creating a minimal webapp with Maven. For a general overview page, please refer to Creating a custom webapp with Maven.
Using Maven to create a webapp allows you to customize your webapp through the POM files, which can be tracked with a version control system like Git. A tailored webapp makes building and deploying faster and has a positive impact on the performance of your instances.
In the steps below, you use the magnolia-dx-core-webapp as the base and exclude the following two modules from it:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>custom-dx-core-project</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>custom-dx-core-project-webapp</artifactId>
<name>custom-dx-core-project: webapp</name>
<packaging>war</packaging>
<dependencies>
<!--
Add your project specific dependencies here:
A custom webapp typically is based on a magnolia webapp. The most simple and reduced bundle to start with is the "magnolia-empty-webapp" (see "option i" below).
To see a complete list of preconfigured Magnolia webapps, have a look at https://documentation.magnolia-cms.com/display/DOCS/Bundles+and+webapps
=> Please just use one of the four below listed options!
Make sure to use the appropriate option (A or B) in the parent pom
-->
<!-- option iii - magnolia-dx-core-webapp -->
<!-- Dependencies versions are already imported by parent pom. Requires "Option B" in the parent pom. -->
<dependency>
<groupId>info.magnolia.dx</groupId>
<artifactId>magnolia-dx-core-webapp</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>info.magnolia.dx</groupId>
<artifactId>magnolia-dx-core-webapp</artifactId>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>info.magnolia.translation</groupId>
<artifactId>magnolia-content-translation</artifactId>
</exclusion>
<exclusion>
<groupId>info.magnolia.translation</groupId>
<artifactId>magnolia-content-translation-pages-integration-app</artifactId>
</exclusion>
<exclusion>
<artifactId>info.magnolia.marketingtags</artifactId>
<groupId>magnolia-marketing-tags</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!-- exclude jars copied "physically" from the webapp overlay - so we only get those resolved by Maven's dependency management -->
<dependentWarExcludes>WEB-INF/lib/*.jar</dependentWarExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
When excluding a module from a webapp, you must check whether other modules, which are still part of the webapp, do not have runtime dependencies to the module you exclude. At the latest, you can discover any unsatisfied runtime dependency during the startup of your Magnolia webapp. Runtime dependencies are defined in the Magnolia Module descriptors.
Adding further resources
The skeleton produced by the Maven archetype has several folders which we have not used so far. This concerns especially the src folder in the webapp subdirectory. In the context of this tutorial page it is the custom-dx-core-project/custom-dx-core-project-webapp/src folder. This folder has the following subfolders:
src/
└── main
└── webapp
├── WEB-INF
│ ├── bootstrap
│ │ ├── author
│ │ ├── common
│ │ └── public
│ └── config
│ └── default
└── docroot
If you leave these subfolders empty, Maven takes the content from the imported webapp, that is the magnolia-dx-core-webapp.
The magnolia-dx-core-webapp inherits from the magnolia-community-webapp.
Customizing the magnolia.properties file
In this step, you add the (default) magnolia.properties file and customize the magnolia.resources.dir property in it.
magnolia.resources.dir is 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.properties and its default value is $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 (symlinks or soft links) in the resources directory to include light modules located elsewhere on your system.
Create the magnolia.properties file in the following folder: custom-dx-core-project/custom-dx-core-project-webapp/src/main/webapp/WEB-INF/config/default/.