summaryrefslogtreecommitdiffstats
path: root/binderVersion.pl
blob: b5b32334376b5d529655deb21039b06281d77396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
if ($#ARGV < 1) {
  print "Usage: binderVersion.pl VER FILE {FILE, FILE}\n";
  exit;
}

$V= $ARGV[0];
# Trim -SNAPSHOT
$V =~ s/-SNAPSHOT//;

print "VER:${V}\r\n";
shift(@ARGV);

sub replace () {
  my $filename = $_[0];

  if(-s $filename) {
    print "Processing [" . $filename . "]\r\n";

    my $original = "$filename.original";
    
    rename($filename, $original);
    open(OUT, ">$filename");
    open(IN, "$original");
    
    while(<IN>) {
      if(/VERSION\s+=\s+".*";/) {
        s/VERSION\s+=\s+".*";/VERSION = "${V}";/;
      } 
      print OUT;
    }
    close(IN);
    close(OUT);
    unlink($original);
  } else {
    print "File [" . $filename . "] does not exist\r\n" 
  }
}

foreach $ARG (@ARGV) {
  do replace($ARG);
}