How to work with a bundle in eclipse when it was downloaded from AEM

耗尽温柔 提交于 2019-12-01 06:25:24

You can use the New Project feature to create the right structure for you:

  • In Eclipse do File > New > Project...
  • Choose AEM > AEM Sample Multi-Module Project > Next
  • Pick the latest Archetype version
  • Enter the Name, Group Id, and Artefact Id > Next
  • Either Add to existing server if there's already one and pick the Location, else choose Setup new server and fill all fields > Finish
  • Wait for Eclipse to finish setting up everything

You now have following projects created for you, which will allow healthy separation of concerns:

  • PROJECT.ui.apps for /apps and /etc content
  • PROJECT.ui.content for /content that is authored
  • PROJECT.core for Java bundles (these will become interesting as soon as you want to add Java code)
  • PROJECT.it.launcher and PROJECT.it.tests for integration tests (you can ignore these as long as you don't run any integration tests)

First, replace the content of your PROJECT.ui.apps project with the apps and etc folders of your package:

  • In the Project Explorer panel, unfold PROJECT.ui.apps > src > main > content > jcr_root > apps
  • Right-click on the apps folder and choose Show In > System Exporer
  • Delete the apps and etc folders that you should now be seeing and place here the apps and etc folders of your of your content package
  • In Eclipse, right-click on the PROJECT.ui.apps project and choose Refresh

Then do the same for the PROJECT.ui.content and replace it's content folder with the one of your package:

  • In the Project Explorer panel, unfold PROJECT.ui.content > src > main > content > jcr_root > content
  • Right-click on the deeper content folder and choose Show In > System Exporer
  • Delete the content folder that you should now be seeing and place here the content folder of your of your content package
  • In Eclipse, right-click on the PROJECT.ui.content project and choose Refresh

Now you have to update the filter.xml files of these two projects to correspond to the content of your content package. For that, open the META-INF/vault/filter.xml file of your content package in a separate text/code editor.

This is an example of how your filter.xml file can look:

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/foo"/>
    <filter root="/apps/foundation/components/bar"/>
    <filter root="/etc/designs/foo"/>
    <filter root="/content/foo"/>
    <filter root="/content/dam/foo"/>
    <filter root="/content/usergenerated/content/foo"/>
</workspaceFilter>

As for the content of your package that got split into two projects, you'll also have to split these filter rules into two and update accordingly the filter.xml files of the two projects.

  • In Eclipse, open PROJECT.ui.apps/src/main/content/META-INF/filter.xml
  • Replace the content of the <workspaceFilter> element with the rules of your package that start with /apps and /etc
  • Then open PROJECT.ui.content/src/main/content/META-INF/filter.xml
  • Replace the rules with the ones of your package that start with /content

Based on the above example, this is how the filter.xml of PROJECT.ui.apps would look:

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/foo"/>
    <filter root="/apps/foundation/components/bar"/>
    <filter root="/etc/designs/foo"/>
</workspaceFilter>

And the one of PROJECT.ui.content:

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/content/foo"/>
    <filter root="/content/dam/foo"/>
    <filter root="/content/usergenerated/content/foo"/>
</workspaceFilter>

Make sure to Save all your changes. You should now be done, and can synchronize that new content to your AEM instance.

  • In the Servers panel, make sure that your connection is [Started], and if not start it
  • Click on the Clean and Publish icon (the last one)

Once done, you should have your package running on your instance, and on save, any change automatically get synchronized to the instance.

If you wish to re-build a package out of your project:

  • Right-click on the PROJECT.ui.apps or PROJECT.ui.content and choose Run As > Maven Install
  • You now have a target folder that has been created with your package inside (called for e.g. PROJECT.ui.apps-0.0.1-SNAPSHOT.zip).
cylinder.y

I suppose you need to create new pom file for downloaded bundle. Here you can see how to create bundle. Also after creating file, you will be able to use maven to deploy bundle after any changes.

If you are using the aem-project-archetype:10 to generate your projects then there will be a few differences/corrections:

The filters files are correctly generated (but in defferent paths):

  • ui.apps\src\main\content\META-INF\vault\filter.xml.
  • ui.content\src\main\content\META-INF\vault\filter.xml.

so, you won't need to fix these files.

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/product-name">
        <exclude pattern="/apps/product-name/install" />
    </filter>
    <filter root="/apps/sling" />
    <filter root="/etc/designs/product-name"/>
</workspaceFilter>


<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/content/product-name"/>
    <filter root="/content/dam/product-name"/>
</workspaceFilter>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!