Using the CoreMedia Blueprint Maven Plugin

The CoreMedia Blueprint Maven Plugin is a Maven convenience utility to help managing the dependencies of CoreMedia project extensions. A CoreMedia Blueprint Maven Plugin usually consists of several artifacts, each extending one of the many applications of the whole CoreMedia project.

Instead of adding or removing each artifact's dependency element to the correct modules one by one, the CoreMedia Blueprint Maven Plugin allows you to add only one dependency element at a central configuration module to activate all of the extension artifacts, each at the right application module.

Overview

The goal of the CoreMedia Blueprint Maven Plugin is to provide a way to enable or disable extensions in a Maven workspace in one place. To reach that a new layer was introduced which is called extension-config. This layer contains modules for each CoreMedia component which will be extended in the project. In this figure you will find two components, the CAE and the Studio. Each component depends on its extension-config module which is illustrated by the arrows.

The extension-config modules contain dependencies on the corresponding modules of the extensions. In this case the module cae-extension-dependencies depends on the my-extension-cae module which contains additional features for the CAE required to realize this extension. The module my-extension-studio contains dependencies which are required to enable the extension features in the Studio.

For each detected enabled extension in the Maven workspace the CoreMedia Blueprint Maven Plugin adds the dependencies on the extension's modules to the corresponding extension-config submodule. If extensions have been disabled the corresponding dependencies can be removed with this plugin easily.

An extension consists of different modules providing different resources for the extension, e.g. source code or configuration files. Each module contains the resources required to extend a certain component. The extension shown in the figure above extends the CAE and the Studio. The CAE will be extended by another view repository providing new views and the Studio will be extended by new UI components.

To expose the extension an Extension Descriptor has to be defined as well. The Extension Descriptor is a simple BOM POM which provides dependency management for the extension modules and declares this module as an extension module. This descriptor is used to enable or disable the extension by importing it to/removing it from the dependency management section of your project.

How it Works

The CoreMedia Blueprint Maven Plugin is a Maven plugin that has to be called from command line. This plugin analyzes the state of extensions in a given CoreMedia Blueprint workspace. According to the state of an extension (either it is enabled or disabled) project dependencies are added or removed or remain unaffected. Besides, extensions can be removed completely from the project and from disk if they are no longer required.

The CoreMedia Blueprint Maven Plugin only changes dependencies in the well defined extension points of a project. Each application that can be extended defines a key prefix e.g. cae for the CoreMedia Content Application Engine. The prefix serves as an identifier for the extension point of an application. A developer providing a CoreMedia Blueprint Maven Plugin can now define at each of his modules which extension point the modules artifact should use. This way the knowledge where to add which dependency to activate an extension is shifted from the workspace maintainer to the extension provider.

The interface for the extension provider consists of several properties to be defined in the properties element of the POM XML files of the extensions modules. The interface for the workspace maintainer consists of one module tree where each submodule defines the extension point for one application type. The dependencies of these modules will be modified automatically by the CoreMedia Blueprint Maven Plugin accordingly to the current extension configuration in advance of the build. The extension configuration itself consists of several POM imports in the root POM of the project and has to be modified by the workspace maintainer in order to add or remove a CoreMedia Blueprint Maven Plugin. To use this mechanism in the CoreMedia project workspace, an application only has to depend on the correct submodule of the module tree defining the extension points. This way the applications module only knows of the existence of its corresponding extension point module and all dependencies of all active extensions will be activated transitively and completely transparent.

Defining Extenions

To define a new extension you have to create a new submodule in the extensions module. Inside this submodule you have to create one extension point module for each component which requires additional dependencies and resources. Each extension point module requires the property coremedia.project.extension.for which describes a comma separated list of the target applications this extension point will enhance. Additionally this module must contain the required dependencies and resources. Each extension provides an Extension Descriptor ()a simple BOM POM), which defines the dependency management for all modules of this extension. Furthermore this Extension Descriptor defines two properties:

  • coremedia.project.extension.name: This property defines the name of the extension. The name can is freely selectable. * coremedia.project.extension.modelVersion: This property defines the model version this extension is written in. It must match the currently used version of the CoreMedia Blueprint Maven Plugin.

Example:

Assume you want to enable an extension A in your CoreMedia system which introduces new view repositories for the CAE and new UI components for the Studio. In this case the CAE requires the new view repository configuration (which is an XML file) and the Studio should be extended with new UI components. Then a module A must be created with three submodules. One module contains the new view repository definition (here: A-cae) and the other module contains the Studio UI components (here: A-studio). A third module acts as a BOM POM and manages all dependencies of module A. This BOM POM also defines two properties coremedia.project.extension.name and coremedia.project.extension.modelVersion.

  |-- pom.xml (module: extensions)
   `-- A
       |-- A-bom
       |   `pom.xml
       |-- A-cae
       |   `-- src
       |   |   `-- main
       |   |       `-- java
       |   |           ` <content beans>
       |    `pom.xml
       |-- A-studio
           `-- src
           |   `-- main
           |       `-- joo
           |          `-- com
           |               `-- coremedia
           |                   `-- UiStudioPlugin.as
            `pom.xml

Activate the CoreMedia Blueprint Maven Plugin

To activate the CoreMedia Blueprint Maven Plugin in your Maven project add the plugin to your project.

   ...
   <build>
     <pluginManagement>
       <plugins>
         <plugin>
           <groupId>com.coremedia.maven</groupId>
           <artifactId>coremedia-blueprint-maven-plugin</artifactId>
           <version>1.0.0</version>
         </plugin>
       </plugins>
     </pluginManagement>
   </build>
   ...

Defining and Maintaining Extension Points

This section describes how to define and maintain extension points.

Extension Point Configuration

To use this extension mechanism you have to create a module named extension-config with submodules for each application you want dependencies to be generated for. The submodules must follow the naming convention [extension identifier]-extension-dependencies. Assume you want to create an extension for the CAE and the Studio you have to create two submodules cae-extension-dependencies and studio-extension-dependencies. These modules have the packaging type POM. These POMs do not contain any dependencies when you create them. The dependencies will be added and removed by the CoreMedia Blueprint Maven Plugin.

 |-- extension-config
 |`-- cae-extension-dependencies
 |    `-- pom.xml
 |`-- server-extension-dependencies
 |    `-- pom.xml

Make your Applications Extensible

To make your applications ready for extensions just depend in your application on the extension point. The CAE requires a dependency on cae-extension-dependencies and the Studio requires a dependency on studio-extension-dependencies.

Activate and Deactivate Extensions

To activate extensions import the Extension Descriptor of the extension (i.e. the BOM POM) in the project's root POM. When this import is removed, the extension is disabled.

 <dependency>
     <groupId>com.coremedia</groupId>
     <artifactId>A-bom</artifactId>
     <version>${project.version}</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

See the Usage and Use Cases sections in order to find mechanisms to apply changed extension configurations to your workspace.

Removing Extensions

Removing an extension means to deactivate it and delete the files from the workspace. See the Usage and Use Cases sections in order to find mechanisms to remove extensionsfrom your workspace.

Examples

You will find further examples in the CoreMedia Blueprint Workspace.