#!/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(\&update_in_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 update_in_finded { if (/pom\.xml$/ && !/^\.git/) { 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"); }