Using the CoreMedia Webresources Maven Plugin

This section describes how to use the CoreMedia Webresources Maven Plugin to transform your web resources to serverimportable content.

Provide the Theme Artifacts

The CoreMedia Webresources Maven Plugin processes a certain kind of dependency:

  • It must be of type "zip".
  • It must be classified as "theme".
  • The actual artifact must be a zip file.
    • The zip file contains the plain web resources, i.e. CSS files, JavaScript files and collateral files like images and fonts.
    • The directory structure of the zip file is arbitrary, however it is recommended to use a single root directory for each theme.
    • There is one special top level directory THEME-METADATA. This name is reserved in the context of a theme artifact. The directory is optional and contains theme definition files which constitute the themes from the single web resources. For details about theme definitions see the Blueprint documentation.

The Blueprint's theme modules provide such artifacts by default.

Depend on the Theme Artifacts

The module which uses this plugin must depend on the themes to be processed. The type and the classifier are important for the plugin to recognize the dependency as a theme to be processed.

    <dependency>
        <groupId>myproject.example.com</groupId>
        <artifactId>my-theme</artifactId>
        <version>1.2.3</version>
        <classifier>theme</classifier>
        <type>zip</type>
        <scope>runtime</scope>
    </dependency>

If the theme depends on other themes, you need an additional pom dependency in order to make your module and this plugin aware of the transitivity:

    <dependency>
        <groupId>myproject.example.com</groupId>
        <artifactId>my-theme</artifactId>
        <version>1.2.3</version>
        <type>pom</type>
        <scope>runtime</scope>
    </dependency>

Activate the CoreMedia Webresources Maven Plugin

Add the following snippet to the build/plugins section of your pom:

    <!-- Create Webresource content in target folder -->
    <plugin>
        <groupId>com.coremedia.maven</groupId>
        <artifactId>coremedia-webresource-content-maven-plugin</artifactId>
        <!-- Provide doctypes to create web resources as content-->
        <dependencies>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>css-importer-lib</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>contentserver-blueprint-component</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.coremedia.cms</groupId>
                <artifactId>cap-importer</artifactId>
                <version>${cms.version}</version>
            </dependency>
            <dependency>
                <groupId>com.coremedia.cms</groupId>
                <artifactId>cap-unified-api</artifactId>
                <version>${cms.version}</version>
            </dependency>
            <dependency>
                <groupId>com.coremedia.cms</groupId>
                <artifactId>serverimportexport</artifactId>
                <version>${cms.version}</version>
            </dependency>
            <dependency>
                <groupId>com.coremedia.cms</groupId>
                <artifactId>cap-client-embedded</artifactId>
                <version>${cms.version}</version>
            </dependency>
            <dependency>
                <groupId>com.coremedia.cms</groupId>
                <artifactId>coremedia-xml</artifactId>
                <version>${cms.version}</version>
            </dependency>
        </dependencies>
        <executions>
            <execution>
                <id>compile-resource-corporate-testdata</id>
                <goals>
                    <goal>compile</goal>
                </goals>
                <phase>compile</phase>
            </execution>
        </executions>
    </plugin>

The plugin uses a temporary content server and the XML immporter internally. Adding the dependencies "css-importer-lib" and "contentserver-blueprint-component" essentially injects the Blueprint's CSS Importer implementation and its doctypes into the plugin. This is not only for flexibility. The plugin has to make some assumptions about the document type model and about the css importer configuration which actually introduces additional constraints regarding customizations.

The plugin needs the Blueprint document types, esp. CMAbstractCode, its subtypes and basically all its properties. In respect of the CSS Importer the plugin assumes that its name remains "css-import", that the dependency includes the importer configuration in form of the "css-import.properties", and that it uses the following properties the same way as the default implementation:

    # This property and the following property will be overwritten by the plugin.
    import.multiResultGeneratorFactory.property.inbox=

    # Please make sure that the position of the transformer also stays the same.
    import.transformer.40.property.targetpath=

Furthermore the plugin needs some components from the cms-core. Your core-version must be injected here.