From 2e56e4fac3e43fca784d625fd3b3deefb6279f2f Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Mon, 7 May 2018 23:12:45 -0400
Subject: [PATCH] updated build scripts to update Java version

---
 bindings/java/build.xml |  1 +
 release/release-unix.pl | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/bindings/java/build.xml b/bindings/java/build.xml
index c0e9de9ed..7b978148f 100755
--- a/bindings/java/build.xml
+++ b/bindings/java/build.xml
@@ -10,6 +10,7 @@
 	</condition>
 	<import file="build-${os.family}.xml"/>
 
+    <!-- Careful changing this because release-windows.pl updates it by pattern -->
 	<property name="VERSION" value="4.6.1"/>
 
 	<!-- set global properties for this build -->
diff --git a/release/release-unix.pl b/release/release-unix.pl
index 942f8ea86..249eb50e7 100755
--- a/release/release-unix.pl
+++ b/release/release-unix.pl
@@ -381,6 +381,40 @@ sub update_libver {
     rename ($OFILE, $IFILE) or die "Error renaming $OFILE";
 }
 
+# update the version in the Java ant build.xml file
+sub update_buildxml {
+
+    print "Updating the version in Java build.xml file\n";
+    
+    my $IFILE = "bindings/java/build.xml";
+    my $OFILE = "bindings/java/build.xml2";
+
+    open (CONF_IN, "<${IFILE}") or 
+        die "Cannot open $IFILE";
+    open (CONF_OUT, ">${OFILE}") or 
+        die "Cannot open $OFILE";
+
+    my $found = 0;
+    while (<CONF_IN>) {
+        if (/name=\"VERSION\"/) {
+            print CONF_OUT "<property name=\"VERSION\" value=\"${VER}\"/>\n";
+            $found++;
+        }
+        else {
+            print CONF_OUT $_;
+        }
+    }
+    close (CONF_IN);
+    close (CONF_OUT);
+
+    if ($found != 1) {
+        die "Error: Found $found (instead of 1) occurrences of Version: in Java Build file";
+    }
+
+    unlink ($IFILE) or die "Error deleting $IFILE";
+    rename ($OFILE, $IFILE) or die "Error renaming $OFILE";
+}
+
 
 # Update the autotools / autobuild files in current source directory
 sub bootstrap() {
@@ -576,6 +610,7 @@ ()
 update_hver();
 update_libver();
 update_pkgver();
+update_buildxml();
 
 bootstrap();
 checkin_vers();
-- 
GitLab