Skip to content

Instantly share code, notes, and snippets.

@dmcnulla
Created December 22, 2015 04:42
Show Gist options
  • Save dmcnulla/d54e1353b14305163841 to your computer and use it in GitHub Desktop.
Save dmcnulla/d54e1353b14305163841 to your computer and use it in GitHub Desktop.
require 'rexml/document'
SELENIUM_PATH = 'project/properties/selenium.version'
SELENIUM_VERSION = "2\.48\.2"
def get_file_list(dir)
Dir.glob("#{dir}/**/pom.xml")
end
def get_xml(pom)
file = File.open(pom)
REXML::Document.new(file)
end
def save_xml(file_name, xml)
File.open(file_name, 'w') do |file|
file.puts(xml)
end
# puts file_name
# puts xml
end
def is_compiler?(plugin)
artifacts = []
plugin.elements.each(ARTIFACT_PATH) do |artifact|
artifacts << artifact.text
end
artifacts[0] == COMPILER_NAME
end
def fix(pom)
# puts pom
myxml = get_xml(pom)
myxml.elements.each(SELENIUM_PATH) do |plugin|
plugin.text = (SELENIUM_VERSION)
end
# puts myxml
save_xml(pom, myxml)
end
poms = get_file_list(ARGV[0])
poms.each do |pom|
begin
fix(pom)
rescue Exception => e
puts "Error updating #{pom}"
puts e.message
puts e.backtrace
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment