1
2if ($#ARGV < 1) {
3  print "Usage: binderVersion.pl VER FILE {FILE, FILE}\n";
4  exit;
5}
6
7$V= $ARGV[0];
8# Trim -SNAPSHOT
9$V =~ s/-SNAPSHOT//;
10
11print "VER:${V}\r\n";
12shift(@ARGV);
13
14sub replace () {
15  my $filename = $_[0];
16
17  if(-s $filename) {
18    print "Processing [" . $filename . "]\r\n";
19
20    my $original = "$filename.original";
21
22    rename($filename, $original);
23    open(OUT, ">$filename");
24    open(IN, "$original");
25
26    while(<IN>) {
27      if(/VERSION\s+=\s+".*";/) {
28        s/VERSION\s+=\s+".*";/VERSION = "${V}";/;
29      }
30      print OUT;
31    }
32    close(IN);
33    close(OUT);
34    unlink($original);
35  } else {
36    print "File [" . $filename . "] does not exist\r\n"
37  }
38}
39
40foreach $ARG (@ARGV) {
41  do replace($ARG);
42}
43