com.cedricwalter:properties-sync-maven-plugin

Apache maven plugin for failing fast at build time when using maven resources filtering with environment based filters. This maven plugin will force you to keep in sync all properties files with the reference.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.cedricwalter
ArtifactId

ArtifactId

properties-sync-maven-plugin
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

com.cedricwalter:properties-sync-maven-plugin
Apache maven plugin for failing fast at build time when using maven resources filtering with environment based filters. This maven plugin will force you to keep in sync all properties files with the reference.
Project URL

Project URL

https://github.com/cedricwalter/properties-sync-maven-plugin
Source Code Management

Source Code Management

https://github.com/cedricwalter/properties-sync-maven-plugin.git

Download properties-sync-maven-plugin

How to add to project

<plugin>
    <groupId>com.cedricwalter</groupId>
    <artifactId>properties-sync-maven-plugin</artifactId>
    <version>1.0</version>
</plugin>

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.3.9
commons-io : commons-io jar 2.5
com.google.guava : guava jar 20.0

provided (1)

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

Project Modules

There are no modules declared in this project.

Introduction

Apache maven plugin for failing fast at build time when using maven resources filtering with environment based <filters>

Scenario

  • You use maven filtering: some files get filtered because they may contains stage dependent values for example.
  • you have some properties files that are used, and need to be kept in sync with another reference.properties.

This maven plugin will force you to keep in sync all properties files with the reference.

In Short it compare files against a reference file and enforce consistency.

Quick Usage

properties-sync-maven-plugin is available in Maven Central.

<plugins>
    <plugin>
        <groupId>com.cedricwalter</groupId>
        <artifactId>properties-sync-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <goals>
                    <goal>properties</goal>
                </goals>
                <phase>process-resources</phase>
                <configuration>
                    <folder>${basedir}/src/main/resources</folder> <!-- optional here for sake of example -->
                    <reference>reference.properties</reference> <!-- optional here for sake of example -->
                    <pattern>[a-zA-Z]*.properties</pattern> <!-- optional here for sake of example -->
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

Complete example

Imagine you have a folder src/main/filters which contains

  • localhost.properties
  • host1.properties

You want to force developer to keep in sync localhost.properties and host1.properties

Example of filtering

<build>              
    <filters>
        <filter>${basedir}/src/main/filters/${hostname}.properties</filter>                   
    </filters>
    
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
                <execution>
                    <id>filter-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                    <configuration>
                        <nonFilteredFileExtensions>
                            <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
                            <nonFilteredFileExtension>zip</nonFilteredFileExtension>
                            <nonFilteredFileExtension>jks</nonFilteredFileExtension>
                            <!-- ... list them all of binary will be broken by maven filtering -->
                            <nonFilteredFileExtension>jar</nonFilteredFileExtension>
                            <nonFilteredFileExtension>tar.gz</nonFilteredFileExtension>
                        </nonFilteredFileExtensions>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
                <groupId>com.cedricwalter</groupId>
                <artifactId>properties-sync-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                        <phase>process-resources</phase>
                        <configuration>
                            <folder>${basedir}/src/main/filters</folder> 
                            <reference>localhost.properties</reference> 
                            <pattern>host1.properties</pattern>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    </plugins>
</build>

The build will now failed if both files do not contains the same number of keys.

Versions

Version
1.0