jsonp-maven-plugin Maven Plugin

A Maven plugin for merging JSON files together via JSONP

License

License

Categories

Categories

Maven Build Tools JSON Data
GroupId

GroupId

com.bobpaulin.maven.jsonp
ArtifactId

ArtifactId

jsonp-maven-plugin
Last Version

Last Version

0.0.7
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

jsonp-maven-plugin Maven Plugin
A Maven plugin for merging JSON files together via JSONP
Project URL

Project URL

https://github.com/bobpaulin/jsonp-maven-plugin
Source Code Management

Source Code Management

https://github.com/bobpaulin/jsonp-maven-plugin

Download jsonp-maven-plugin

How to add to project

<plugin>
    <groupId>com.bobpaulin.maven.jsonp</groupId>
    <artifactId>jsonp-maven-plugin</artifactId>
    <version>0.0.7</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 2.0
org.codehaus.plexus : plexus-utils jar 3.0.8
javax.json : javax.json-api jar 1.1
org.glassfish : javax.json jar 1.1

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.8.2

Project Modules

There are no modules declared in this project.

jsonp-maven-plugin

A maven plugin for applying patches to json resources

Usage

Override

An override will overlay one JSON file over another. It will append new fields and overwrite existing ones.

For example given a source json file named source.json

{"test":"Test1"}

And a override json file named override.json

{"test2":"Test2"}

The output will be:

{"test":"Test1","test2":"Test2"}

The plugin configuration required will look like this

  <build>
    <plugins>
      ...
      <plugin>
        <groupId>com.bobpaulin.maven.jsonp</groupId>
        <artifactId>jsonp-maven-plugin</artifactId>
        <version>0.0.3</version>
        <executions>
          <execution>
            <id>merge</id>
            <phase>validate</phase>
            <goals>
              <goal>merge</goal>
            </goals>
            <configuration>
                <sourceFile>src/main/resources/source.json</sourceFile>
                <overrideSourceFile>src/main/resources/override.json</overrideSourceFile>
                <outputFile>${project.build.directory}/test/out.json</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>

Patch

A patch uses a JSON Pointer to replace a specific section of a source json document.

For example given a source json file named source.json

{"test":"Test1"}

And a patch json file named patch.json

[
    { "op": "add", "path": "/test2", "value": "Test2" }
]

The output will be:

{"test":"Test1","test2":"Test2"}

The plugin configuration required will look like this:

  <build>
    <plugins>
    ...
      <plugin>
        <groupId>com.bobpaulin.maven.jsonp</groupId>
        <artifactId>jsonp-maven-plugin</artifactId>
        <version>0.0.3</version>
        <executions>
          <execution>
            <id>merge</id>
            <phase>validate</phase>
            <goals>
              <goal>merge</goal>
            </goals>
            <configuration>
                <sourceFile>src/main/resources/source.json</sourceFile>
                <patchFile>src/main/resources/patch.json</patchFile>
                <outputFile>${project.build.directory}/test/out.json</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>

Versions

Version
0.0.7
0.0.5
0.0.4
0.0.3