Skip to content

Instantly share code, notes, and snippets.

@denishaskin
Created February 22, 2012 18:45
Show Gist options
  • Save denishaskin/1886595 to your computer and use it in GitHub Desktop.
Save denishaskin/1886595 to your computer and use it in GitHub Desktop.
Summarize profile properties in a maven pom.xml
# 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