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.
Usage
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 Name | Type | Default Value | Description |
---|---|---|---|
version | String | "1.2.1" | The version of the Liferay AMD Module Config Generator to use. |
Tasks
The plugin adds two tasks to your project:
Name | Depends On | Type | Description |
---|---|---|---|
configJSModules | downloadLiferayModuleConfigGenerator , processResources | ConfigJSModulesTask | Generates the configuration file needed to load AMD files via combo loader in Liferay. |
downloadLiferayModuleConfigGenerator | downloadNode | DownloadNodeModuleTask | Downloads 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 Name | Default Value |
---|---|
moduleConfigFile | "${project.projectDir}/package.json" |
outputFile | "${sourceSets.main.output.resourcesDir}/META-INF/config.json" |
sourceDir | "${sourceSets.main.output.resourcesDir}/META-INF/resources" |
The plugin also adds the following dependencies to tasks defined by the java
plugin:
Name | Depends On |
---|---|
classes | configJSModules |
If the com.liferay.js.transpiler
plugin is applied, the configJSModules
task is configured to always run after
the transpileJS
task.
ConfigJSModulesTask
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 Name | Default Value |
---|---|
includes | ["**/*.es.js*", "**/*.soy.js*"] |
scriptFile | "${downloadLiferayModuleConfigGenerator.moduleDir}/bin/index.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
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.