The following section describes the Commerce Store Accelerator-specific tasks that are defined in the allprojects
closure of the root build.gradle
script. These tasks are accessible to all Commerce Store Accelerator build projects. Because task order in the build script matters, tasks are presented in this document in the same order as they appear in the build.gradle
script.
Note: A number of the following sections reference the project /build
directory. A /build
directory is created within each project when you run Gradle and Gradles places its compiled classes, resources and JAR files in that directory as part of its build process.
jshint
The jshint
task runs the JSHint plugin to validate Commerce Store Accelerator JavaScript code for style and formatting. If this task finds any errors, the build fails. For more information on JSHint, see http://www.jshint.com/.
pluginsManifestBuilder
When you create an application module (for example, B2Cstore
) you must include a gradle.properties
file in the module that defines an includedPlugins
property. This property specifies the list of Commerce Store Accelerator plugins on which the application depends, for example:
includedPlugins=\ CommerceAccelerator.Applications.B2CStore.Plugins.Account \ CommerceAccelerator.Applications.B2CStore.Plugins.Checkout \ CommerceAccelerator.Applications.B2CStore.Plugins.SearchAndNavigation \ CommerceAccelerator.Applications.B2CStore.Plugins.Spotlights \ CommerceAccelerator.Applications.B2CStore.Plugins.ShoppingCart \ CommerceAccelerator.Plugins.Preview \ CommerceAccelerator.Plugins.Checkout \ CommerceAccelerator.Plugins.Promotions \ CommerceAccelerator.Plugins.SEO
The pluginsManifestBuilder
task then uses the includedPlugins
property to create a MANIFEST.MF
file in the application module’s directory structure. For example, the following is the MANIFEST.MF
file from CommerceAccelerator/Applications/B2CStore/Plugins/META-INF
:
Manifest-Version: 1.0 ATG-Required: CommerceAccelerator.Applications.B2CStore.Plugins.Accoun t CommerceAccelerator.Applications.B2CStore.Plugins.Checkout Commerce Accelerator.Applications.B2CStore.Plugins.SearchAndNavigation Commerc eAccelerator.Applications.B2CStore.Plugins.Spotlights CommerceAcceler ator.Applications.B2CStore.Plugins.ShoppingCart CommerceAccelerator.P lugins.Preview CommerceAccelerator.Plugins.Checkout CommerceAccelerat or.Plugins.Promotions CommerceAccelerator.Plugins.SEO
Note that each line length in the manifest is limited to 72 bytes to conform to standard JAR file specifications. Any lines longer than 72 bytes are continued on the next line and must start with a single space.
composeDeployFromBaseAndPlugins
The composeDeployFromBaseAndPlugins
task, in conjunction with the composeDeployFromEacTemplates
task, creates the deployment templates for the EAC applications that will support your Commerce Store Accelerator application module.
To begin, the composeDeployFromBaseAndPlugins
task creates a CommerceAccelerator/Applications/
CSA-
application-name
/src/main/deploy/
EAC-application-name
/
directory for each EAC application. These directories hold the deployment template for each EAC application. The number of directories to create, and their names, are defined by the eacApplications
property in the /CommerceAccelerator/Applications/
CSA-application-name
/gradle.properties
file. For example, the B2CStore
application defines the following EAC applications in its gradle.properties
file:
eacApplications=\ CSAde,\ CSAen,\ CSAes
After creating the EAC application directories, the composeDeployFromBaseAndPlugins
task copies deployment template fragments from the Base
module and each included plugin into those directories. To determine which plugins contribute to the deployment, the composeDeployFromBaseAndPlugins
task references the includedPlugins
property specified in the application’s gradle.properties
file. The source files that composeDeployFromBaseAndPlugins
copies from are found in the CommerceAccelerator/Base/src/main/deploy
and CommerceAccelerator/Plugins/
plugin
/src/main/deploy
directories.
composeDeployFromEacTemplates
The composeDeployFromEacTemplates
task, in conjunction with the composeDeployFromBaseAndPlugins
task, creates the deployment templates for the EAC applications that will support your Commerce Store Accelerator application module. Specifically, the composeDeployFromEacTemplates
task copies deployment template fragments from two locations:
From this source:
/CommerceAccelerator/Applications/
CSA-application-name
/src/main/eac-templates/common
To each of the EAC application deploy directories:
/CommerceAccelerator/Applications/
CSA-application-name
/src/main/deploy/
EAC-application-name
The
/common
source directory contains configuration settings that remains consistent across all EAC applications and its contents are copied into each EAC application deploy directory. If you need to specify EAC application configuration settings that are the same across all your EAC applications, put them in the/common
source directory.From this source:
/
CommerceAccelerator/Applications/
CSA-application-name
/src/main/eac-templates/
EAC-application-name
To the corresponding
/CommerceAccelerator/Applications/
CSA-application-name
/src/main/deploy/
EAC-application-name
directory. The source/EAC-application-name
directories contain configuration settings, namely/content
and/pages
, that are specific to the individual EAC applications.
The /CommerceAccelerator/Applications/
CSA-application-name
/src/main/deploy
directory is deleted each time a Gradle build is run, so you must put your EAC application configuration into the correct source directories, from which it may be copied to the /deploy
directory.
Also, note that each EAC application requires a deploy.xml
file, located in /CommerceAccelerator/Applications/
CSA-application-name
/src/main/deploy/
EAC-application-name
, in order to deploy the application to the Workbench.
bowerInstall
The bowerInstall
task allows Gradle to install Bower by invoking the bower install
command from the command line. The uiInstall
task uses the bowerInstall
task when it installs the third-party libraries that modules with web applications depend on. This task is an Exec
task.
bowerClean
The bowerClean
task removes the bower_components
directory from current project. This task should be used whenever Bower component versions have been updated to ensure that the old versions get removed and version conflicts do not occur. For example, if a version of Knockout gets updated in the bower.json
file, this task ensures that the old version of Knockout gets removed.
npmInstall
The npmInstall
task allows Gradle to install Node by invoking the npm install
command from the command line. The uiInstall
task uses the npmInstall
task when it installs the third-party libraries that modules with web applications depend on. This task is an Exec
task.
uiInstall
The uiInstall
task runs installer commands for the third-party libraries that modules with web applications depend on. Specifically, this task runs the bowerInstall
and npmInstall
tasks to install Bower and Node.
If a module has a package.json
file, uiInstall
invokes the npmInstall
task for that module, using the configuration specified in the package.json
file. Out of the box, the only module that includes a package.json
file is the root CommerceAccelerator
module.
Similarly, if a module has a .bowerrc
file, uiInstall
invokes the bowerInstall
task for that module, using the configuration specified in the .bowerrc
file. For example, the CommerceAccelerator/Base
module contains a .bowerrc
file that specifies the Bower configuration for the CommerceAccelerator/Base/src/main/web-app
.
all
The all
task allows you to invoke all the required tasks to build Commerce Store Accelerator with the command gradle all
.
cleanAll
The cleanAll
task removes a project’s /build
directory along with any classes, resources, and JAR files it contains.
cleanDeploy
The cleanDeploy
task removes the EAC application deployment templates by deleting the contents of the Commerce Store Accelerator application’s /deploy
directory. See the composeDeployFromBaseAndPlugins and composeDeployFromEacTemplates sections for more details on the /deploy
directory.
copyClasses
The copyClasses
task copies compiled Java classes from a project’s build directory (for example, CommerceAccelerator/Applications/<application>/build
) into the project’s classes
directory (for example, CommerceAccelerator/Applications/<application>/classes
). This task depends on the Java plugin’s compileJava
task completing first.
copyLibs
The copyLibs
task copies the assembled JAR file from a project’s build directory (for example, CommerceAccelerator/Applications/<application>/build
) into the project’s lib
directory (for example, CommerceAccelerator/Applications/<application>/lib
). ). This task depends on the Java plugin’s assemble
task completing first.
buildWar
The buildWar
task assembles the store.war
implementation, including third-party libraries as well as custom JavaScript and HTML code, for a Commerce Store Accelerator application and places it in the application’s CommerceAccelerator/Applications/<application>/src/main/j2ee-apps
directory. Because this assembly process is application-specific, the buildWar
task in the root project is empty. You should override the buildWar
task implementation in the build.gradle
file of your Commerce Store Accelerator application’s module. The empty buildWar
task is defined in the root build.gradle
file so that it can be invoked from the all
task.
runGrunt
The runGrunt
task is used to invoke the grunt
command-line execution task. When the current working project contains a src/main/web-app
directory, a custom grunt Exec task is executed. This task adds the grunt task named gradle
to the argument list, thereby telling the grunt Exec task to run the gradle
task that has been defined in the CommerceAccelerator/.Gruntfile.js
configuration. The gradle
task is used to run additional grunt tasks that compile and optimize Commerce Store Accelerator’s JavaScript.
The optimize task takes an application module’s individual .js
files and merges them into a single, large JavaScript file. This allows the browser to load the site using a single request, as opposed to hundreds of requests for the individual JavaScript files. The list of files to merge is specified in the include
array of an application module’s Gruntfile.js
file (CommerceAccelerator/Applications/
application-name
/Gruntfile.js
).
The compile task runs two additional tasks, customizeBootstrap
and less
, both of which are defined in CommerceAccelerator/Base/Gruntfile.js
. Bootstrap contains a number of source .less
files (for example, alerts.less
, badges.less
, navbar.less
, and so on) that contain styles for the various Bootstrap components. It also contains a bootstrap.less
file that imports the constituent .less
files. In order to customize Bootstrap without modifying the original source files, Commerce Store Accelerator has its own versions of the .less
files that need modification. These custom .less
files first import the original .less
file, then modify the styles. The customizeBootstrap
grunt task creates a new bootstrap.less
file that replaces the import paths for any overridden .less
files. The less
task compiles all .less
files into .css
files.