5

I downloaded a zip from a running instance of AEM from package manager - http://localhost:4502/crx/packmgr/index.jsp. The zip file, when extracted contains, jcr_root and META-INF.

I would like to build some functionality on top of this zip file. So I'm wondering if there is a way to work with this file in eclipse? However, there are no pom.xml files in this zip folder. So I can't just import it in Eclipse. I have AEM developer tools downloaded for Eclipse.

Is there a guide available that explains how to do this? The zip file contains some Java files and I would like to make changes to those Java files and re-package, re-deploy, so that I can test my changes.

I tried using Adobe Brackets (with AEM extension) but it only works well for JS or JSP changes...not for JAVA files.

Update

After @Gabriel's comment, this is my understanding of how I need to move around from the package I downloaded to the new project created via eclipse.

enter image description here

After doing the above

Here is what the new eclipse project looks like after I've copy/pasted everything

enter image description here

Contents of filter.xml from downloaded package

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

Based on above I changed two filter.xml in following locations

/myproj.ui.apps/src/main/content/META-INF/vault/filter.xml

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/myproject">
        <exclude pattern="/apps/myproject/install" />
    </filter>
    <filter root="/apps/foundation/components/parsys" />
    <filter root="/etc/designs/delta"/>
</workspaceFilter>

/myproj.ui.content/src/main/content/META-INF/vault/filter.xml

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

Doing clean/publish seemed to have no effect as I didn't see anything in CRX or localhost:4502/siteadmin after doing clean/publish. So I tried to install manually.

For that I did Run as -> Maven Install on myproj (which builds the following zip files)

~/Documents/workspace/myproj $ tree | grep "zip"
│       ├── myproj.ui.apps-0.0.1-SNAPSHOT.zip
        ├── myproj.ui.content-0.0.1-SNAPSHOT.zip

When I upload & install these two files to CRX I see the following:

enter image description here enter image description here

However, this also seems to not be having any effect because I don't see anything in localhost:4502/siteadmin and when I visit localhost:4502/content/myproj I get an error

``

BTW this is what I see under localhost:4502/siteadmin

enter image description here

Update 2

After going through everything again I was able to create the eclipse project and was successful in clean/publishing. However, changes to JAVA files aren't being reflected when I do clean/publish.

@Gabriel mentioned that

PROJECT.core for Java bundles (these will become interesting as soon as you want to add Java code)

I have java files already that are in PROJECT.ui.apps as shown in the image below

enter image description here

If I make a change to this JAVA file and clean/publish, my changes aren't being reflected in AEM. Is there something else that needs to be done to be able to change and publish JAVA code? or How can I make changes to JAVA files and test that on AEM?

birdy
  • 9,286
  • 24
  • 107
  • 171
  • 1
    I've updated my answer. I think that your `filter.xml` in `myproj.ui.apps` should filter `/apps/delta` instead of `/apps/myproject`. Similar error for `myproj.ui.content` where you should filter for `/content/delta` and `/content/dam/delta` instead of `*/myproject`. – Gabriel Walt Apr 18 '15 at 13:16
  • The Java bundles that are in your `/apps` structure have to be moved into `PROJECT.core`, or their synchronization won't work. The reason is that content projects (like `PROJECT.ui.apps` and `PROJECT.ui.content`) are synched into JCR, while bundle projects (like `PROJECT.core`) must be synched into OSGi. But then you also have to edit accordingly the POM.xml of `PROJECT.core`, which is not trivial. – Gabriel Walt Apr 18 '15 at 20:45
  • @GabrielWalt Thanks, I will try to move the JAVA files from `/apps` to `PROJECT.core`. I'll read up on how to edit the POM.xml according to that. Any hints regarding it? – birdy Apr 18 '15 at 23:29
  • You can have a look at following page: http://docs.adobe.com/docs/en/cq/5-6-1/developing/developmenttools/how-to-build-aem-projects-using-apache-maven.html – Gabriel Walt Apr 20 '15 at 09:24

3 Answers3

9

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).
Gabriel Walt
  • 1,629
  • 17
  • 19
  • I've been able to create the project now. However, the project has JAVA files and when I change them and then do clean/publish, the changes don't seem to be taking effect on AEM. Changing JS, JSP, CSS files seems to be taking effect with clean/publish. But not JAVA files. – birdy Apr 18 '15 at 17:25
  • One issue I observed was, when we create new project (windows, eclipse luna), finish filling all details. It moves eclipse to non-responding state for about 2-5 mins, and then project is created. Is this known behavior? – Sandeep Kumar Apr 25 '16 at 10:14
0

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.

Community
  • 1
  • 1
dzenisiy
  • 855
  • 10
  • 32
0

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>