Created
February 25, 2018 21:37
-
-
Save chtz/980b703c1d4526b693aa4fa5c1f1daea to your computer and use it in GitHub Desktop.
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
require 'nokogiri' | |
def open_pom | |
File.open("pom.xml") { |f| Nokogiri::XML(f) } | |
end | |
def save_pom(pom) | |
File.open('pom.xml','w') {|f| pom.write_xml_to f} | |
end | |
def get_version(pom) | |
pom.xpath("/x:project/x:version", 'x' => 'http://maven.apache.org/POM/4.0.0').first.content | |
end | |
def set_version(pom, version) | |
pom.xpath("/x:project/x:version", 'x' => 'http://maven.apache.org/POM/4.0.0').first.content = version | |
end | |
def unsnapshot(version) | |
version =~ /(\d+\.\d+\.\d+)/ | |
$1 | |
end | |
def resnapshot(version) | |
version =~ /(\d+\.\d+)\.(\d+)/ | |
$1 + "." + ($2.to_i + 1).to_s + "-SNAPSHOT" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment