Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
Last active December 17, 2015 20:28
Show Gist options
  • Select an option

  • Save gcmurphy/5667417 to your computer and use it in GitHub Desktop.

Select an option

Save gcmurphy/5667417 to your computer and use it in GitHub Desktop.
Patch all supplied pom.xml files to use the victims-enforcer plugin.
#!/usr/bin/env ruby
require 'nokogiri'
ARGV.each do |file|
puts "Patching #{file}.."
f = File.open(file)
doc = Nokogiri::XML(f)
f.close
#doc.remove_namespaces!
node = doc.at('//pom:build/pom:plugins', 'pom'=>'http://maven.apache.org/POM/4.0.0')
Nokogiri::XML::Builder.with(node) do |xml|
xml.plugin {
xml.groupId "org.apache.maven.plugins"
xml.artifactId "maven-enforcer-plugin"
xml.version "1.1.1"
xml.dependencies {
xml.dependency {
xml.groupId "com.redhat.victims"
xml.artifactId "enforce-victims-rule"
xml.version "1.2"
}
}
xml.executions {
xml.execution {
xml.id "enforce-victims-rule"
xml.goals {
xml.goal "enforce"
}
xml.configuration {
xml.rules{
xml.rule(:implementation => "com.redhat.victims.VictimsRule"){
xml.metadata "warning"
xml.fingerprint "warning"
xml.updates "auto"
}
}
}
}
}
}
end
File.open(file, 'w'){ |f| f.write(doc) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment