Packaging the customization

In this lesson, you package your customization to prepare it for deployment. You can package and deploy your profit margin related customization files into your production environment with the WebSphere Commerce Build and Deployment tool.

About this task

The WebSphere Commerce Build and Deployment tool is designed to address the error-prone and time-consuming nature of customized asset deployment. The tool provides a starting point for you to automate your build and deployment processes in a standardized, controlled manner. For more information, see WebSphere Commerce Build and Deployment tool.

Important: The package and deployment process replaces files on the deployment target server. Ensure that no previous customization will be removed or replaced by the customization changes that you made in this tutorial.

Procedure

Prepare the source package for both the WebSphere Commerce EAR customization and WebSphere Commerce search EAR customization.
  1. WebSphere Commerce EAR package:
    1. Create the source code repository to include the Data Load utility files and code packages for your updated product recommendation widget customization code.
      1. Copy the WCDE_installdir\wcbd folder to a temporary location, such as under C:\.
      2. Rename the directory to be wcbd-deploy-server-local-profit_margin_wc.

        This directory is referred to as the wcbd_wc directory in this task.

      3. Create the following directory structure: wcbd_wc/source/workspace.
    2. Add the Data Load utility files, which load customized data on the server side, into your source code repository for the WebSphere Commerce Build and Deployment tool.
      1. Create the file structure wcbd_wc/source/workspace/dataload/dataload/common for your Data Load utility files.
      2. Add the Data Load utility files for your custom widget into your source code repository for the Build and Deployment tool. The directory should resemble the following structure in the wcbd_wc/source/workspace/dataload/dataload/common directory:
        • dataload_cost_price directory
        • dataload_price_list directory
        • wc-dataload-env.xml file
        The dataload_cost_price and dataload_price_list must include the price list and cost price data that you previously loaded. For more information about creating the wc-dataload-env.xml file, see Configuring the data load environment settings. The environment settings in this file must match the environment settings for your target environment where you are deploying your customization.
    3. Copy all of the customization folders and files to the wcbd_wc/source/workspace directory.
      1. Create the directory structure: wcbd_wc/source/workspace/Stores
      2. Copy the following files from the workspace_dir\Stores directory to the wcbd_wc/source/workspace/Stores directory.
        • WebContent/widgetdir/com.ibm.commerce.store.widgets.CatalogEntryRecommendation/CatalogEntryRecommendation_Data.jspf
        • WebContent/widgetdir/Common/PriceDisplay/PriceDisplay_Data.jspf
        • WebContent/widgetdir/Common/PriceDisplay/PriceDisplay_UI.jspf
        The directory should resemble the following structure in the wcbd_wc/source/workspace directory:
        • dataload directory
        • Stores directory
    The contents of your packaged wcbd_wc assets can resemble the contents of the following sample file.
  2. WebSphere Commerce Search package:
    1. Create the source code repository to include the Data Load utility files and code packages for your search customization code.
      1. Copy the WCDE_installdir\wcbd folder to a temporary location, for example, under C:\
      2. Rename the directory to wcbd-deploy-server-local-profit_margin_solr.

        This directory is referred to as the wcbd_solr directory in this task.

      3. Create the following directory structure: wcbd_solr/source/workspace.
    2. Add the Data Load utility files which load customized data on the server side into your source code repository for the WebSphere Commerce Build and Deployment tool.
      1. Create the file structure under wcbd_solr/source/workspace/dataload/dataload/common for your Data Load utility files.
      2. Add the Data Load utility files for your custom search configuration into your source code repository for the WebSphere Commerce Build and Deployment tool.
        The directory should resemble the following structure in the wcbd_solr/source/workspace/dataload/dataload/common directory:
        • dataload_search_attr directory
        • wc-dataload-env.xml file
    3. Copy all of the customization folders and files to the wcbd_solr/source/workspace directory.
      1. Create the file structure: wcbd_solr/source/workspace
      2. Copy the following files from the workspace_dir\Search directory to the wcbd_solr/source/workspace directory:
        • Search/xml/config/com.ibm.commerce.catalog-ext/wc-search.xml
        • Search/xml/config/com.ibm.commerce.catalog-ext/wc-component.xml
      3. Create the file structure: wcbd_solr/source/workspace/Search-Rest
      4. Copy the following file from the workspace_dir\Search-Rest directory to the the wcbd_solr/source/workspace/Search-Rest directory:
        • WebContent/WEB-INF/config/com.ibm.commerce.rest-ext/wc-rest-resourceconfig.xml
      The directory should resemble the following structure in the wcbd_solr/source/workspace directory:
      • Dataload directory
      • Search directory
      • Search-Rest directory
      The contents of your packaged wcbd_solr assets can resemble the contents of the following sample file.
Prepare the automated extraction Ant scripts and configure the build setting.
Important: Steps 3-5 must be performed on both the wcbd_wc and wcbd_solr packages. In these steps, wcbd_wc is used as the example. You need to repeat the same steps for wcbd_solr directory.
  1. Set up the source extraction Ant script. The Ant script extracts the source code from the source code repository that you created.
    1. Go to the extract directory for the package you are preparing.
      For example, wcbd_wc/extract.
    2. Copy the wcbd-sample-extract-local.properties and wcbd-sample-extract-local.xml files into the asset directory one level above it.
      For example, either wcbd_wc.
    3. Rename the copied wcbd-sample-extract-local.xml file to extract-local.xml.
    4. Open the extract-local.xml file for editing.
    5. Locate the following line of code:
      
      <project name="wcbd-sample-extract-local" default="all">
      
    6. Replace it with the following code:
      
      <project name="extract-local" default="all">
      
    7. Save and close the file.
    8. Rename the copied wcbd-sample-extract-local.properties file to extract-local.properties.
    9. Open the extract-local.properties file for editing.
    10. Set the value for local.extract.dir= to wcdb_wc/source
      Note: In all of the properties files that your WebSphere Commerce Build and Deployment tool uses, you must use forward slashes in the file paths. Otherwise, the build process fails.
  2. Configure the WebSphere Commerce Build and Deployment tool build settings.
    1. Go to the Ant_installdir\lib directory.
    2. Copy the ant-contrib-1.0b3.jar file into the WCBD_installdir/lib directory.
    3. Download and extract the following file: XMLUpdate.zip.

      Copy the extracted XMLUpdate.jar file into the WCBD_installdir/lib directory.

    4. Create a copy of the wcbd-build.private.properties.template file and rename the copied file to build-local.private.properties.
    5. Create a copy of the wcbd-setenv.bat file and rename the copied file to setenv.bat.
    6. Open the setenv.bat file for editing.
    7. Change the value of ANT_HOME to Ant_installdir.
      For example, C:/apache-ant-1.9.2.
    8. Ensure that the value of WAS_HOME is correct.
    9. Create a copy of the wcbd-build.properties.template file and rename the copied file to build-local.properties.
    10. Open the build-local.properties file, under the WebSphere Commerce EAR source package. Set the following properties:
      
      app.type=wc
      extract.ant.file=${basedir}/extract-local.xml
      web.module.list= Stores
      wc.home=WCDE_installdir
      was.home=WAS_home
      Note: For the build-local.properties in the wcbd_solr directory, set the following properties
      
      app.type=search
      extract.ant.file=${basedir}/extract-local.xml
      web.module.list=Search-Rest
      wc.home=WCDE_installdir
      was.home=WAS_home
  3. Obtain the deployment packages for both the WebSphere Commerce EAR and WebSphere Commerce search EAR.
    1. Open a command prompt and go to the wcbd_wc directory.
    2. Run the following command:
      
      wcbd-ant.bat -buildfile wcbd-build.xml -Dbuild.label=profit_margin_wc -Dbuild.type=local
      
      Note: For the wcbd_solr package, run the following command instead:
      
      wcbd-ant.bat -buildfile wcbd-build.xml -Dbuild.label=profit_margin_solr -Dbuild.type=local
      
      Where the value for the -Dbuild.label parameter is the name of your package. Set the value for the parameter to the value that you want to name your package.
      For example, the previous commands name the packages profit_margin_solr and profit_margin_wc.
      When the command runs, the Build and Deployment tool creates two deployment packages:
      1. A package for production server deployment.
      2. A package for IBM WebSphere Commerce Developer server deployment.
      The packages are in the WCBD_installdir/dist and wcbd_solr/dist directories. The packages for deploying the customization in a production environment resemble the following sample packages:Download and extract these packages to a temporary directory in your target deployment environment for reference.
  4. For the WebSphere Commerce search EAR package, copy the customization related files that are outside of the workspace_dir directory.
    Note: This step is required for the search package only. As a limitation of the Build and Deployment tool, files outside of workspace_dir directory cannot be compiled and packed. Therefore, you must manually copy any files that are not in that directory and include the copied files into your deployment package.
    1. In a file manager utility, go to the wcbd_solr/dist/server directory.
    2. Extract the wcbd-deploy-server-local-profit_margin_solr.zip compressed file.
    3. Within the extracted file structure, browse to the wcbd-deploy-server-local-profit_margin_solr/source directory. If your target deployment environment is another development environment, go to the wcbd_solr/dist/toolkit directory instead.
    4. Create a folder and name the folder SearchConfig.
    5. Copy the following files from the Solrhome\MC_masterCatalogId\locale\CatalogEntry\conf directory into your newSearchConfig directory:
      • solrcore.properties
      • x-data-config.xml
      • x-schema.xml
    6. Package the extracted wcbd-deploy-server-local-profit_margin_solr directory that now includes the SearchConfg directory and files into a new wcbd-deploy-server-local-profit_margin_solr.zip compressed file.