Created
February 22, 2012 18:45
-
-
Save denishaskin/1886595 to your computer and use it in GitHub Desktop.
Summarize profile properties in a maven pom.xml
This file contains 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
# Summarize profile properties in a maven pom.xml | |
# Parameter: pom.xml filename | |
# Output: tab-delimited table of profiles & properties | |
require 'crack/xml' | |
x = Crack::XML.parse(File.new(ARGV[0])) | |
m = {} | |
all_properties = {} | |
x['project']['profiles']['profile'].each do |p| | |
m[p['id']] = {} | |
m[p['id']]['activeByDefault'] = 'X' if p['activation'] and p['activation']['activeByDefault'] | |
all_properties['activeByDefault'] = true | |
p['properties'].keys.each do |pr| | |
all_properties[pr] = true | |
m[p['id']][pr] = p['properties'][pr] | |
end | |
end | |
puts ([''] + m.keys.sort).join("\t") | |
all_properties.keys.sort.each do |pr| | |
props = m.keys.sort.collect do |profile| | |
m[profile][pr] | |
end | |
puts ([pr] + props).join("\t") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment