JS Module Config Generator Gradle Plugin

The JS Module Config Generator Gradle plugin lets you run the Liferay AMD Module Config Generator to generate the configuration file needed to load AMD files via combo loader in Liferay.

The plugin has been successfully tested with Gradle 4.10.2.


To use the plugin, include it in your build script:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.js.module.config.generator", version: "2.1.57"

    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"

apply plugin: "com.liferay.js.module.config.generator"

The JS Module Config Generator plugin automatically applies the com.liferay.node plugin.

Project Extension

The JS Module Config Generator plugin exposes the following properties through the extension named jsModuleConfigGenerator:

Property NameTypeDefault ValueDescription
versionString"1.2.1"The version of the Liferay AMD Module Config Generator to use.


The plugin adds two tasks to your project:

NameDepends OnTypeDescription
configJSModulesdownloadLiferayModuleConfigGenerator, processResourcesConfigJSModulesTaskGenerates the configuration file needed to load AMD files via combo loader in Liferay.
downloadLiferayModuleConfigGeneratordownloadNodeDownloadNodeModuleTaskDownloads the Liferay AMD Module Config Generator in the project’s node_modules directory.

By default, the downloadLiferayModuleConfigGenerator task downloads the version of liferay-module-config-generator declared in the jsModuleConfigGenerator.version property. If the project’s package.json file, however, already lists the liferay-module-config-generator package in its dependencies or devDependencies, the downloadLiferayModuleConfigGenerator task is disabled.

The configJSModules task is automatically configured with sensible defaults, depending on whether the java plugin is applied:

Property NameDefault Value

The plugin also adds the following dependencies to tasks defined by the java plugin:

NameDepends On

If the com.liferay.js.transpiler plugin is applied, the configJSModules task is configured to always run after the transpileJS task.


Tasks of type ConfigJSModulesTask extend ExecuteNodeScriptTask, so all its properties and methods, such as args, inheritProxy, and workingDir, are available. The ConfigJSModulesTask instances also implement the PatternFilterable interface, which lets you specify include and exclude patterns for the files in sourceDir to process.

They also have the following properties set by default:

Property NameDefault Value
includes["**/*.es.js*", "**/*.soy.js*"]

The purpose of this task is to run the Liferay AMD Module Config Generator from the included files in sourceDir. The generator processes these files and creates a configuration file in the location specified by the outputFile property.

Task Properties

Property NameTypeDefault ValueDescription
configVariableStringnullThe configuration variable to which the modules should be added. It sets the --config argument.
customDefineString"Liferay.Loader"The namespace of the define(...) call to use in the JS files. It sets the --namespace argument.
ignorePathbooleanfalseWhether not to create module path and fullPath properties. It sets the --ignorePath argument.
keepFileExtensionbooleanfalseWhether to keep the file extension when generating the module name. It sets the --keepExtension argument.
lowerCasebooleanfalseWhether to convert file name to lower case before using it as the module name. It sets the --lowerCase argument.
moduleConfigFileFilenullThe JSON file which contains configuration data for the modules. It sets the --moduleConfig argument.
moduleExtensionStringnullThe extension for the module file (e.g., .js). If specified, use the provided string as an extension instead to get it automatically from the file name. It sets the --extension argument.
moduleFormatStringnullThe regular expression and value to apply to the file name when generating the module name. It sets the --format argument.
outputFileFilenullThe file where the generated configuration is stored. It sets the --output argument.
sourceDirFilenullThe directory that contains the files to process.

The properties of type File support any type that can be resolved by project.file. Moreover, it is possible to use Closures and Callables as values for the int and String properties to defer evaluation until task execution.

« Javadoc Formatter Gradle PluginJS Transpiler Gradle Plugin »
Was this article helpful?
0 out of 0 found this helpful