Creating a New Extension
Extension templates enable you to create your own extensions that you can then use for specific implementations.
SAP Commerce comes with an extension generator system called extgen.
Using extgen, you can create new extensions based on extension templates. A number of extension templates are available.
Optional: Setting Default Values for New Extensions
You can personalize extgen default behavior by modifying the project.properties file located in <HYBRIS_BIN_DIR>/platform/extgen. Extgen then uses your settings as the default to generate the extension.
Modifying the default values is only necessary for advanced settings. Extgen prompts you to provide the basic values during the extension generation process.
Copy an Extension Template Using Extgen
An extension template is a predefined basic extension to be duplicated. The copy serves as a starting point for creating a new extension, typically used for customer-specific implementations.
-
Open a command prompt.
-
Navigate to the <HYBRIS_BIN_DIR> /platform directory.
-
Run the <HYBRIS_BIN_DIR> /platform/setantenv.bat file. Don't close the command prompt as the settings are transient and are lost if the command prompt is closed.
-
Run ant extgen in <HYBRIS_BIN_DIR>/platform directory. This internally runs ant in the extgen directory.
Extgen prompts you to specify values for the technical aspects of an extension. Extgen comes with default values for all these technical aspects. These default values are defined in the project.properties file in the extgen directory. The default value is displayed in brackets ([ and ]), such as:
Press [Enter] to use the default value [training]
You can simply use the default value by pressing Enter.
Extgen prompts you to specify:
-
The extension's name.
-
The extension's Java package.
-
The extension template to use.
For a list of available extension templates compatible with extgen, see Available Extension Templates.
After you have provided the prompted values, extgen:
-
Copies the extension template to a temporary directory.
-
Modifies the extension template to reflect the specified values.
-
Copies the new extension from the temporary directory to the directory specified by the extgen.extension.path property in the project.properties file.
After the copy process is completed, the extension is ready to be referenced in the localextensions.xml.
Reference the New Extension in localextensions.xml File
To make sure that an extension is integrated into the build framework, you need to reference the extension in the localextensions.xml file. Note that this file contains references to folders from which it loads extensions:
<path autoload="true" dir="${HYBRIS_BIN_DIR}/modules/cockpit-applications"/>
<path dir="${HYBRIS_BIN_DIR}"/>
<extension name="yempty" />
<extension name="samlsinglesignon" />
Hence, if you want to add a new extension, myextension, add this line to localextensions.xml:
<extension name="myextension"/>
For details, see Installation Based on Specified Extensions.
For more information, see Building SAP Commerce.
Before you proceed, remove all references to template extensions from localextensions.xml.
Rebuild SAP Commerce
-
Open a command prompt.
-
Navigate to the <HYBRIS_BIN_DIR>/platform directory.
-
Make sure that a compliant version is used:
-
On the Windows operating system, call the <HYBRIS_BIN_DIR>/platform/setantenv.bat file. Do not close the command prompt after this call as the settings are transient and would get lost if the command prompt is closed.
-
On the Unix operating system, call the <HYBRIS_BIN_DIR>/platform/setantenv.sh file, such as: . ./setantenv.sh.
-
-
Call ant clean all to build the entire SAP Commerce.
Configure an Extension
An extension is configured by the extensioninfo.xml file. It defines the contained extension modules and list of extensions that the current extension depends on.
To define properties of the extension, use the local.properties file. See also Configuring the Behavior of SAP Commerce.