mage/Utils/version-bump.pl

65 lines
1.6 KiB
Perl
Raw Normal View History

2011-09-20 19:53:19 +00:00
#!/usr/bin/perl -w
use strict;
use File::Copy;
use File::Find;
open ROOTPOM, "< ../pom.xml" or die;
my $oldversion;
while (<ROOTPOM>) {
my $line = $_;
if ($line =~ m/mage-version>(.*)</) {
print "Current version: $1\n";
$oldversion = $1;
}
}
print "Enter new version: ";
my $version = <STDIN>;
chomp $version;
2012-05-06 20:36:50 +00:00
find(\&update_in_finded, "..");
2011-09-20 19:53:19 +00:00
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");
2012-05-06 20:36:50 +00:00
sub update_in_finded {
if (/pom\.xml$/ && !/^\.git/) {
2011-09-20 19:53:19 +00:00
update_version($_);
}
}
sub update_version {
my ($filename) = @_;
open POM, "< $filename" or die;
open NEWPOM, "> $filename.new" or die;
while (<POM>) {
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 (<FILE>) {
s/new MageVersion\($of, $os, $ot,/new MageVersion\($f, $s, $t,/;
print NEWFILE $_;
}
close FILE;
close NEWFILE;
move("$filename.new", "$filename");
}