Extgen and Modulegen


Lets Understand about Extgen and Modulegen with example


Extgen

How to create an extension in Hybris?

Ant extgen command can be used to create an extension.

We have to use ant extgen command as below

Navigate to hybris\bin\platform path in command prompt

And use ant extgen command

ant_extgen

Provide the required values

ant_extgen_success

Specify the extension template,name of the extension and package name while running this command

Extension template should be any of the existing extension templates which are populated when we run the ant extgen command

This command uses the specified extension template to create the structure of the new extension.

Name of the extension we provide will be added as the name inside the extensioninfo.xml file.

Now observe that new extension has been created inside hybris\bin\custom folder.

extgen_extension_folder

Update localextensions.xml

Once we create the new extension we must add it inside localextensions.xml so that hybris will consider this extension during the build.

So add an extension inside localextensions.xml as below

  1. extension name=”payment”
extension name=”payment”

Payment – is the name of the extension.


Make custom extension as Extension Template

We can make our custom extension also as extension template so that it appears in the list of extension templates during ant extgen command

To achieve this , we need to define the below tag in extensioninfo.xml

  1. meta key="extgen-template-extension" value="true"
meta key="extgen-template-extension" value="true" 

Adding this enables our extension to appear in the ant extgen command templates list.

Modulegen


Ant modulegen command can be used to create the module.

It creates the set of extensions based on the module template we select.

Generally for B2B and B2C module , it creates 7 extensions which are logically related and grouped.

We have to use ant modulegen command as below

Navigate to hybris\bin\platform path in command prompt

And use ant modulegen command

ant_modulegen

Specify the module template,name of the module and package name while running this command

Module template should be any of the existing module templates which are populated when we run the ant modulegen command

ant_modulegen_success

This command uses the specified module template to create the set of the extensions to the new module.

modulegen_success

After the build success, observe the new set of extensions has been created inside hybris\bin\custom\training folder.

modulegen_extensions_folder
After the creation of extensions using modulegen, make sure to update the localextensions.xml file as below

  1. <extension name='trainingcockpits' />
  2. <extension name='traininginitialdata' />
  3. <extension name='trainingstorefront' />
  4. <extension name='trainingfacades' />
  5. <extension name='trainingfulfilmentprocess' />
  6. <extension name='trainingtest' />
  7. <extension name='trainingcore' />
<extension name='trainingcockpits' />
<extension name='traininginitialdata' />
<extension name='trainingstorefront' />
<extension name='trainingfacades' />
<extension name='trainingfulfilmentprocess' />
<extension name='trainingtest' />
<extension name='trainingcore' />

About the Author

Founder of javainsimpleway.com
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to kb.knowledge.sharing@gmail.com

Connect with me on Facebook for more updates

Share this article on