Reputation: 977
I am working on Hybris and I generated a new extension using hybris command (ant extgen) with default settings. During extension generation, I did not change default values like I let the project name to be "training". I started developing some code just for the sake of trying it but now I wrote quite a lot of code and instead of generating a new extension, I am trying to rename "training" to a new name which is more suitable for my project.
My question is - Is there any shortcut to rename "training" to a new name. By rename I don't mean standard intellij or eclipse module rename but also updating all extension specific properties which are referring to extension name "training". Is there any hybris ant command for it?
Upvotes: 2
Views: 1641
Reputation: 5810
Here is the way I can think of.
You can declare your extension as a template for extgen
and then generate a new extension based on it with a new name and structure.
Let me take training
as your current extension which you want to convert to some other name. Below are the steps you need to perform.
<meta key="extgen-template-extension" value="true"/>
Look like
<coremodule generated="true" manager="org.training.jalo.TrainingManager" packageroot="org.training"/>
<meta key="extgen-template-extension" value="true"/>
<webmodule jspcompile="false" webroot="/training"/>
Please note, If your current extension is with a different name then training in that case you need to change below values accordingly.
extgen.properties:
`YEXTNAME_TOKEN=training
YMODULE_TOKEN=training
YMODULE_PACKAGE_ROOT=training
YMODULE_CLASS_PREFIX=training
YPACKAGE_TOKEN=org.training
YMANAGER_TOKEN=TrainingManager
YCLASSPREFIX_TOKEN=Training
YGENERATED_TOKEN=Generated `
Run ant extgen and select your extension (training) from the given selection option and give the name and package the way you want when it prompt for it.
Now replace training extension with the newly created extension inside localextensions.xml
Test and patch wherever needed! :-)
EDIT:
YEXTNAME_TOKEN - This is a token that is used during the cloning process to rename an extension with the value entered by user.
YMODULE_TOKEN - This is a token that is used during the cloning process to give a new name to the module.
YMODULE_PACKAGE_ROOT - This property is added to the root of the cloned extension package name for all classes.
YMODULE_CLASS_PREFIX - Prefix for the extension's classes.
YPACKAGE_TOKEN - The base package in your extension's extensioninfo.xml.
YMANAGER_TOKEN - The manager class in your extension's extensioninfo.xml.
YCLASSPREFIX_TOKEN - The class prefix in your extension's extensioninfo.xml.
YGENERATED_TOKEN - The generated prefix is used for classes that will be generated during extension build process.
Upvotes: 5
Reputation: 797
No it is not possible. The generated extension itself was created from a template where the word "training" is inserted into many places (class names, package names, configurations...) .
The other approach would be to look into the ext-template folder (6.7). There are all templates. Search for any token in the templates and make appropriate change in your generated extensions. Depending on the amount of your extensions, it will also take some time... and you need to understand how extgen works, first.
Upvotes: 0
Reputation: 1822
I don't think so. It might also be easier just to create a new one and move the code into the new extension.
Upvotes: 0