Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Implement a custom Package Exporter for Sling Distribution

Avatar

Level 2

Requirement:

Currently, the Sling Distribution Forward Agents utilize the Apache Sling Distribution Packaging – Vault Package Builder Factory to export packages. However, I want to configure a custom Package Builder that can export or replicate files in their native format instead of using the Vault packaging mechanism.

In other words, the goal is to export the content as-is — for example:

  • If the file is a JSON, it should be exported as a JSON file.

  • If it’s an HTML file, export it as HTML.

  • If it’s an image, export it as an image.

At present, the default Vault packaging exports the data in a binary (vault) format, which is not desirable for this use case.

I would like to understand whether this can be achieved through configuration or if it requires a custom code implementation, so I can proceed accordingly.

ac4320_0-1761072203067.png
ac4320_1-1761072236963.png

ac4320_2-1761072283946.png

Currently using the default vault packaging in my forward agent :

ac4320_3-1761072346006.png

 

 

3 Replies

Avatar

Level 2

Do we have something like JSON package Builder? I was going through https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/issue-is-sling-content-dis... which says 

  • Package builder mismatch (FileVault vs JSON).

So is there a JSON package builder available? If so - where is it and how to configure the same?

@VishalKa5 - Can you let me know if there's any such thing?

As of now I just want to focus on JSON only - any insights with the above use-case would be very helpful.


Thanks!

Avatar

Community Advisor

Hi @ac4320,

Short answer - No, Sling Distribution doesn’t include a JSON package builder. The default “Vault Package Builder Factory” always exports in FileVault format. If you want the content to be distributed as raw JSON, HTML, or binary files (instead of zipped JCR content), you’ll need to implement a custom DistributionPackageBuilder.

Here are the details:

  • The default builder PID is:
    org.apache.sling.distribution.serialization.impl.vlt.VaultDistributionPackageBuilderFactory

  • You can create your own builder by implementing the interface
    org.apache.sling.distribution.packaging.DistributionPackageBuilder.
    Inside your implementation, you can:

    • Read resources under the given paths (DistributionRequest)

    • Serialize them directly as JSON (using Sling’s ResourceResolver + JsonRenderer)

    • Write them to an output stream or a temporary file

  • Then register it as an OSGi component (e.g. name=json) and update your Forward Agent config to reference it:

     
    Package Builder: (name=json)

Example use case:
If your content under /content/data/*.json should be replicated as JSON files, your builder could simply export those nodes via Sling’s JSON exporter instead of creating a Vault package.

References:


Santosh Sai

AEM BlogsLinkedIn


Avatar

Level 2

@SantoshSai - Can you please help me with the code?