ct-jsregistry-maven-plugin

The ct-jsregistry-maven-plugin provides tools to optimize the JavaScript and CSS source code and is a helper for artifact deployment. This section describes the configuration properties.

Goals

help

Display help for the ct-jsregistry-maven-plugin.

> mvn de.conterra.jsregistry:ct-jsregistry-maven-plugin:<version>:help -Ddetail=true

Set <version> to your current ct-jsregistry version, e.g: 1.0.0

Parameter Default Description

detail

false

If true, display all settable properties for each goal.

goal

-

The name of the goal to show help for. If unspecified, all goals are displayed.

indentSize

2

The number of spaces per indentation level, should be positive.

lineLength

80

The maximum length of a display line, should be positive.

buildPacksProperties

Builds a META-INF/js-registry-packs.properties file. It should be used in JAR-projects to keep the metadata files up to date.

Binds by default to the process-resources lifecycle.

buildPacksProperties Sample
<plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>buildPacksProperties</id>
            <goals>
                <goal>buildPacksProperties</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <sourceDirectory>${project.build.directory}/${project.artifactId}/js</sourceDirectory>
        <outputDirectory>${project.build.directory}/${project.artifactId}/js</outputDirectory>
        <scanPackagesIncludes>**</scanPackagesIncludes>
        <scanPackagesExcludes>**/tests/**,sample/**,apps/**</scanPackagesExcludes>
    </configuration>
</plugin>
Parameter Default Description

sourceDirectory

${project.build.outputDirectory}

The source folder to scan for packages

outputDirectory

${project.build.outputDirectory}

The output directory into which the packs is written.

scanPackagesExcludes

Glob patterns defining the directories to exclude during scan for packages. Relative to sourceDirectory.

scanPackagesIncludes

**

Glob patterns defining the directories to include during scan for packages. Relative to sourceDirectory.

buildRegistryIndex

Builds a bundles.json file in the outputDirectory containing all meta information about available bundles in the file system. This goal is helpful if no JS registry service is available, for example in offline apps.

Binds by default to the process-resources lifecycle.

buildPacksProperties Sample
<plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>build bundles.json</id>
            <goals>
                <goal>buildRegistryIndex</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <sourceDirectory>${project.build.directory}/${project.artifactId}/js</sourceDirectory>
        <outputDirectory>${project.build.directory}/${project.artifactId}/js</outputDirectory>
        <scanPackagesIncludes>**</scanPackagesIncludes>
        <scanPackagesExcludes>**/tests/**,sample/**,apps/**</scanPackagesExcludes>
        <inlinePackageJson>true</inlinePackageJson>
        <outputFile>bundles.json</outputFile>
    </configuration>
</plugin>
Parameter Default Description

sourceDirectory

${project.build.outputDirectory}

The source folder to scan for packages.

outputDirectory

${project.build.outputDirectory}

The output directory into which the packs is written.

scanPackagesExcludes

Glob patterns defining the directories to exclude during scan for packages. Relative to sourceDirectory.

scanPackagesIncludes

**

Glob patterns defining the directories to include during scan for packages. Relative to sourceDirectory.

inlinePackageJson

true

Inlines the manifest.json and package.json infos of all bundles.

outputFile

bundles.json

Name of the registry file to create.

convertManifestToPackage

Converts manifest.json files to package.json files. This is a goal normally used on the command line to upgrade a project to the new format.

Binds to no specific lifecycle phase.

convertManifestToPackage commandline sample
mvn de.conterra.jsregistry:ct-jsregistry-maven-plugin:<version>:convertManifestToPackage \
    -Dmanifest.input=${project.build.sourceDirectory} \
    -Dmanifest.output=${project.build.sourceDirectory} \
    -Dmanifest.includes=** \
    -Dmanifest.excludes=**/tests/** \
    -Dmanifest.delete=true
convertManifestToPackage Sample
<plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>convertManifestToPackage</id>
            <goals>
                <goal>convertManifestToPackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <sourceDirectory>${project.build.directory}/${project.artifactId}/js</sourceDirectory>
        <outputDirectory>${project.build.directory}/${project.artifactId}/js</outputDirectory>
        <scanPackagesIncludes>**</scanPackagesIncludes>
        <scanPackagesExcludes>**/tests/**</scanPackagesExcludes>
        <deleteManifestFiles>true</deleteManifestFiles>
    </configuration>
</plugin>
Parameter Default Description

outputDirectory

${project.build.sourceDirectory}

The output directory

sourceDirectory

${project.build.sourceDirectory}

The classes folder to scan for packages.

scanPackagesExcludes

Glob patterns defining the directories to exclude during scan for packages. Relative to classesDirectory.

scanPackagesIncludes

**

Glob patterns defining the directories to include during scan for packages. Relative to classesDirectory.

deleteManifestFiles

false

Whether the converted manifest.json should be deleted after the package.json has been created.

optimizeCSS

Compresses CSS files in a directory.

Binds by default to the process-resources lifecycle.

optimizeCSS Sample
 <plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>optimize-css</id>
            <goals>
                <goal>optimizeCSS</goal>
            </goals>
            <configuration>
                <sourceDirectory>${project.build.directory}/${project.artifactId}</sourceDirectory>
                <outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>
                <cssFiles>
                    <includes>
                        <include>js/bundles/base/themes/themes/*/*.css</include>
                        <include>js/bundles/base/templates/templates/*/*.css</include>
                    </includes>
                    <excludes>
                        <exclude>**/themeSettings.css</exclude>
                    </excludes>
                </cssFiles>
            </configuration>
        </execution>
    </executions>
</plugin>
Parameter Default Description

onlyStripComments

false

Whether to only remove comments and whitespace.

advancedCompression

true

Whether to remove comments and whitespace and perform some other CSS compression task.

breakLines

false

Whether to break lines so that one line is not too long for some environments

outputDirectory

${project.build.outputDirectory}

The output directory to which the optimized CSS files are written.

sourceDirectory

${project.build.outputDirectory}

The directory in which the CSS files are located.

inlineIncludes

true

Whether to inline include statements in the CSS files.

keepIncludes

""

A comma-separated list of includes that should be preserved, for example ../testInclude.css,[next].css

checkSelectorLimit

true

Whether to check for the Internet Explorer CSS selector limit of 4095 selectors per file. If the limit is reached, the input file is split into multiple files.

cssFiles

<cssFiles>
 <includes>
 <include>**/*.css</include>
 </includes>
</cssFiles>

include/exclude pattern used to find CSS files.

<cssFiles>
  <includes>
    <include>**/*.css</include>
   </includes>
   <excludes>
     <exclude>**/dijit/**</exclude>
   </excludes>
</cssFiles>

optimizeJS

Scans each package/bundle and optimizes single JavaScript files. — compress — inlineStrings

Binds by default to the compile lifecycle.

optimize Sample
 <plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>optimize-js</id>
            <goals>
                <goal>optimizeJS</goal>
            </goals>
            <configuration>
                <sourceDirectory>${project.build.directory}/${project.artifactId}</sourceDirectory>
                <outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>
                <jsFiles>
                    <includes>
                       <include>myfile.js</include>
                    </includes>
                    <excludes>
                       <exclude>donotinclude.js</exclude>
                    </excludes>
                </jsFiles>
                <hasFeatures>
                    <ct-debug>false</ct-debug>
                </hasFeatures>
            </configuration>
        </execution>
    </executions>
</plugin>
Parameter Default Description

inlineStrings

true

Whether to inline imported HTML resources in the generated output files.

compress

true

Whether to compress the output files using the closure compiler.

stripConsole

""

Whether to remove console.debug() statements from the output files. This works only if compress is true. Valid values are "warn", "error", "all" or "".

jsFiles

Include/exclude pattern used to find JS files in sourceDirectory.

<jsFiles>
    <includes>
       <include>myfile.js</include>
    </includes>
    <excludes>
       <exclude>donotinclude.js</exclude>
    </excludes>
</jsFiles>

hasFeatures

-

Static has features (see dojo/has ) which are introduced in the source code during build. Allows execution path removal during build time. This works only if optimize is true.

For example, the following setting in the pom.xml file states that JavaScript code blocks enclosed in has("ct-debug") are removed:

<hasFeatures>
    <ct-debug>false</ct-debug>
</hasFeatures>

The JavaScript code looks like this before optimizing:

constructor: function (topic, properties) {
    if (has("ct-debug")) {
        validateTopicName(topic);
    }
    var p = new Hash(properties);
}

The complete if-block is removed, if has("ct-debug") evaluates to false. This results in the following code after optimizing:

constructor: function (topic, properties) {
    // "has" block has been removed
    var p = new Hash(properties);
}

outputDirectory

${project.build.outputDirectory}

The output directory in which all dependencies.json files are generated.

sourceDirectory

${project.build.outputDirectory}

The directory in which all relative js paths are calculated too.

scanPackagesExcludes

Glob patterns defining the directories to exclude during scan for packages. Relative to classesDirectory.

scanPackagesIncludes

**

Glob patterns defining the directories to include during scan for packages. Relative to classesDirectory.

calculateDependencies

Calculates dependencies.json files for each AMD package/bundle. This goal is required for the buildLayers goal.

Binds by default to process-resources lifecycle.

calculateDependencies Sample
<plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>calc-deps</id>
            <goals>
                <goal>calculateDependencies</goal>
            </goals>
            <configuration>
                <sourceDirectory>${project.build.directory}/${project.artifactId}</sourceDirectory>
                <outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>
                <skipPackages>dojo,dijit,dojox,esri,dgrid,put-selector,xstyle</skipPackages>
            </configuration>
        </execution>
    </executions>
</plugin>
Parameter Default Description

dependenciesFileName

dependencies.json

The name of the generated 'dependency' files (dependencies.json).

skipPackages

-

List of AMD packages (like bundles) that should not be traversed. The package names must be separated by commas like in the following example: ct,dijit,dojo,map

outputDirectory

${project.build.outputDirectory}

The output directory where all dependencies.json files are generated.

sourceDirectory

${project.build.outputDirectory}

The directory to search for packages.

scanPackagesExcludes

Glob patterns defining the directories to exclude during the scan for packages. Relative to classesDirectory.

scanPackagesIncludes

Glob patterns defining the directories to include during the scan for packages. Relative to classesDirectory.

buildLayers

This goal concatenates different JavaScript files into one file. Such a file is called "layer". It requires dependency information from the dependencies.json file which is created by the calculateDependencies goal.

Binds by default to process-classes lifecycle.

buildLayers Sample
<plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>build-layers</id>
            <goals>
                <goal>buildLayers</goal>
            </goals>
            <configuration>
                <sourceDirectory>${project.build.directory}/${project.artifactId}</sourceDirectory>
                <outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>
                <layers>
                    <layer>
                        <name>apps/mylayer</name>
                        <includes>
                            <include>system</include>
                            <include>themes</include>
                            <include>templates</include>
                        </includes>
                        <excludes>
                            <!-- Attention: this removes not only mapflow, but also also all of its dependencies! For one large layer file not needed! -->
                            <exclude>mapflow</exclude>
                            <exclude>!esri/*</exclude>
                        </excludes>
                        <!-- By default en is included in the layer file -->
                        <locales>
                            <locale>de</locale>
                        </locales>
                    </layer>
                </layers>
            </configuration>
        </execution>
    </executions>
</plugin>
Parameter Default Description

dependenciesFileName

dependencies.json

How are the generated 'dependency' files are named (dependencies.json).

layers

-

The JS layer definitions. Example:

<layers>
    <layer>
        <name>ct/mapapps_small</name>
        <includes>
            <include>contentflow</include>
            <include>dojox/widget/FileList</include>
        </includes>
        <excludes>
            <!-- Attention: this removes not only mapflow, but also also all of its dependencies! For one large layer file not needed! -->
            <exclude>mapflow</exclude>
            <exclude>!ct/_singlefile</exclude>
            <exclude>!esri/*</exclude>
            <exclude>esri/*</exclude>
        </excludes>
        <!-- By default en is included to the layer file -->
        <locales>
            <locale>de</locale>
        </locales>
    </layer>
</layers>

include and exclude can use short bundle names or full AMD identifiers like "dojox/widget/Wizard".

name is an AMD identifier and can be an existing file. The dependencies of the file are included in the target file and the body, too.

The following special include patterns are supported:

<AMD identifier> =

include the file and all dependencies of that file → use exclude pattern to restrict the includes.

The next include patterns are only of interest for direct plain JavaScript file inclusion, which are not AMD files. These patterns are only useful, if you try to make a layer, which should contain dojo.js and dojo-init.js or other plain initialization scripts. The files are considered as non AMD and the dependencies are ignored.

^<AMD identifier> =

means include the file contents before the require({cache…​}) statement.

+<AMD identifier> =

means include the file contents after the require({cache…​}) statement.

The following special exclude patterns are supported:

<AMD identifier> =

means exclude this file and all dependencies of the file.

!<AMD identifier> =

means exclude this single file, but integrate its dependencies.

+<AMD identifier> =

means exclude the dependencies of the file, but allow to include the single file.

<AMD prefix>/* =

exclude all files which have the given AMD prefix and their dependencies.

!<AMD prefix>/* =

exclude only the files which have the given AMD prefix, but include their dependencies.

e.g: !esri/* means that all files from the esri api package should not be included in the layer.

outputDirectory

${project.build.outputDirectory}

The output directory for the layer files.

sourceDirectory

${project.build.outputDirectory}

The directory where all relative JavaScript source files are located.

scanPackagesExcludes

Glob patterns defining the directories to exclude during scan for packages. Relative to classesDirectory.

scanPackagesIncludes

deployJSPackage

Uploads a ZIP or a JAR file containing JavaScript packages to the JS Registry.

Binds by default to the package lifecycle.

buildPacksProperties Sample
<plugin>
    <groupId>de.conterra.jsregistry</groupId>
    <artifactId>ct-jsregistry-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>deploy-bundles</id>
            <goals>
                <goal>deployJSPackage</goal>
            </goals>
            <configuration>
                <registryEndpoint>http://localhost:8080/resources/jsregistry</registryEndpoint>
                <file>${project.build.directory}/${project.build.finalName}.jar</file>
                <username>admin</username>
                <password>admin</password>
            </configuration>
        </execution>
    </executions>
</plugin>
Parameter Default Description

registryEndpoint

http://localhost:8080/resources/jsregistry

URL pointing to the JS Registry server.

file

${project.build.directory}/${project.build.finalName}.jar

The file containing the packages to upload (zip/jar).

username

Username to authenticate against the registry.

password

Password to authenticate against the registry.

sslTrustAnyServer

true

Defines if the plugin trusts any SSL servers without checking a trust store.

useChunkedRequestEncoding

true

Defines that content upload is using Chunked Request Encoding. If false uploads are buffered in memory to calculate the content length.