Apache Sling Feature Diff Tool

Clone this repo:
  1. 3e7bc10 SLING-8580 - [feature-diff] exclude 'service.pid' and by Simo Tripodi · 3 months ago master
  2. 82f4a63 SLING-8579 - [feature-diff] ServiceLoader does not correctly load by Simo Tripodi · 3 months ago
  3. 44c4b97 [maven-release-plugin] prepare for next development iteration by Simo Tripodi · 4 months ago
  4. a5e3e3a [maven-release-plugin] prepare release org.apache.sling.feature.diff-0.0.2 by Simo Tripodi · 4 months ago org.apache.sling.feature.diff-0.0.2
  5. d9a22e2 @releng back to 0.0.1 version before consolidating the APIs by Simo Tripodi · 4 months ago

Apache Sling Feature Model diff tool

This tool aims to provide to Apache Sling users an easy-to-use tool which is able to detect differences between different released version of the same Apache Sling Feature Model.

Simple APIs

Given two different versions of the same org.apache.sling.feature.Feature, all we need to do is comparing them

import static org.apache.sling.feature.diff.FeatureDiff.compareFeatures;

import org.apache.sling.feature.Feature
import org.apache.sling.feature.diff.DiffRequest;
import org.apache.sling.feature.diff.DiffRequest;

...

Feature previous = // somehow obtained
Feature current = // somehow obtained

DiffRequest diffRequest = new DiffRequest()
                          .setPrevious(previous)
                          .setCurrent(current)
                          .setResultId("org.apache.sling:org.apache.sling.diff:1.0.0");

Feature featureDiff = compareFeatures(diffRequest);

The resulting featureDiff is a new Feature instance which prototypes from previous and where necessary removals sections are populated and new elements may be added.

###Please note

The FeatureDiff.compareFeatures(Feature, Feature) rejects (aka throws an IllegalArgumentException) Feature inputs that:

  • are null (bien sûr);
  • refer exactly to the same Feature.

Excluding sections

The DiffRequest data object can be configured in order to include/exclude one ore more Feature section(s), available are:

  • bundles
  • configurations
  • extensions
  • framework-properties

Users can simply add via the include/exclude methods the section(s) they are interested:

DiffRequest diffRequest = new DiffRequest()
                          .setPrevious(previous)
                          .setCurrent(current)
                          .addIncludeComparator("bundles")
                          .addIncludeComparator("configurations")
                          .setResultId("org.apache.sling:org.apache.sling.diff:1.0.0");

Feature featureDiff = compareFeatures(diffRequest);