View on GitHub

PME @ Red Hat

Standardize Your Builds

Json Manipulation

Overview

PME offers the ability to modify one or many json files in the repository prior to running the build.

Configuration

The manipulator is controlled by the jsonUpdate property. The format is

-DjsonUpdate=<file>:<json-xpath-expression>:[<replacement-value>] [,....]

Multiple comma separated values may be supplied. If the replacement-value is not specified the operation becomes a delete rather than an update.

The format for the xpath-style expression is specified in the JSON-Path project here.

Note: Any ‘,’ or ‘:’ in the path expression or replacement value should be escaped with ‘\’.

As an example:

-DjsonUpdate='manager/ui/war/npm-shrinkwrap.json:$..resolved:,distro/data/src/main/resources/data/basic-settings.json:$..version:1.3.1.rebuild-1'

This means:

  1. For the file manager/ui/war/npm-shrinkwrap.json
    • Use the path expression $..resolved to deep scan for resolved.
    • As there is no replacement, these are then deleted.
  2. For the file distro/data/src/main/resources/data/basic-settings.json
    • Use the path expression $..version to deep scan for version.
    • Replace the value with 1.3.1.rebuild-1