Created
July 25, 2013 10:46
-
-
Save VadimKirilchuk/6078634 to your computer and use it in GitHub Desktop.
Outputs difference between two java property files. Using just diff is not enough because properties can have different order, duplicated or commented,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (this.args.length < 2) { throw new IllegalArgumentException("Please, give path to baseline properties and path to other properties")} | |
def excludeList = [/log4j\./] | |
File baseline = this.args[0] as File | |
File other = this.args[1] as File | |
Properties baselineProps = new Properties() | |
baseline.withInputStream { stream -> baselineProps.load(stream) } | |
Properties otherProps = new Properties() | |
other.withInputStream { stream -> otherProps.load(stream) } | |
baselineProps.each { key, value -> | |
if (excludeList.find { key =~ it }) { return } | |
def otherValue = otherProps.get(key) | |
if (!otherProps.containsKey(key)) { | |
println "- ${key}=${value}" | |
} else if (otherValue != value) { | |
println "! ${key}=[${value} | ${otherValue}]" | |
} | |
} | |
otherProps.each { key, value -> | |
if (excludeList.find { key =~ it }) { return } | |
if (!baselineProps.containsKey(key)) { | |
println "+ ${key}=${value}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment