diff --git a/Utils/version-bump.pl b/Utils/version-bump.pl new file mode 100644 index 0000000000..de5f59f0da --- /dev/null +++ b/Utils/version-bump.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl -w + +use strict; +use File::Copy; +use File::Find; + +open ROOTPOM, "< ../pom.xml" or die; + +my $oldversion; +while () { + my $line = $_; + if ($line =~ m/mage-version>(.*); +chomp $version; + +#find(\&finded, ".."); +update_version_in_java("../Mage.CLient/src/main/java/mage/client/MageFrame.java"); +update_version_in_java("../Mage.Server/src/main/java/mage/server/Main.java"); +update_version_in_java("../Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java"); + +sub finded { + if (/pom\.xml/) { + update_version($_); + } +} + +sub update_version { + my ($filename) = @_; + open POM, "< $filename" or die; + open NEWPOM, "> $filename.new" or die; + while () { + s/version>$oldversion/version>$version/g; + print NEWPOM $_; + } + close POM; + close NEWPOM; + move("$filename.new", "$filename"); +} + +sub update_version_in_java { + my ($filename) = @_; + open FILE, "< $filename" or die; + open NEWFILE, "> $filename.new" or die; + $version =~m/(.)\.(.)\.(.)/; + my ($f, $s, $t) = ($1, $2, $3); + $oldversion =~m/(.)\.(.)\.(.)/; + my ($of, $os, $ot) = ($1, $2, $3); + print "f - $f, s - $s, t - $t\n"; + while () { + s/new MageVersion\($of, $os, $ot,/new MageVersion\($f, $s, $t,/; + print NEWFILE $_; + } + close FILE; + close NEWFILE; + move("$filename.new", "$filename"); +} + +