How to rename an existing Hybris extension

北城以北 提交于 2020-01-05 04:38:15

问题


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 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 ?


回答1:


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.

  1. Make sure your extension (training) is there in the localextensions.xml
  2. Update extensioninfo.xml to mark the extension as a template by adding below meta tag

    <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"/>
    
  3. Create an extgen.properties inside training extension/folder with below properties

    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

  4. 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.

  5. Now replace training extension with the newly created extension inside localextensions.xml

  6. Test and patch wherever needed! :-)




回答2:


I don't think so. It might also be easier just to create a new one and move the code into the new extension.




回答3:


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.



来源:https://stackoverflow.com/questions/56670019/how-to-rename-an-existing-hybris-extension

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!