Fix shell script directories.

The build flags affect the `bazel info bazel-bin` output and must match
those used during `bazel build`.

The path to the files from the data attribute of the build rule differs
when built from gerrit than when built from plugins/copyright, but the
differences are reflected in the ${TEST_BINARY} dirname.

Change-Id: Ide5bb8abdb39c5835b3b9a00b1f67abf2a0e7e46
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/AndroidScanTest.sh b/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/AndroidScanTest.sh
index bcaf29b..cb3a3eb 100755
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/AndroidScanTest.sh
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/AndroidScanTest.sh
@@ -14,8 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-readonly scanner="${TEST_SRCDIR}/copyright/android_scan"
-readonly testdata="${TEST_SRCDIR}/copyright/src/test/java/com/googlesource/gerrit/plugins/copyright/testdata"
+readonly root=$(dirname "${TEST_BINARY}")
+readonly scanner="${root}/android_scan"
+readonly testdata="${root}/src/test/java/com/googlesource/gerrit/plugins/copyright/testdata"
 
 function die() {
   echo -e "$@" >&2
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/ScanToolTest.sh b/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/ScanToolTest.sh
index beb23cd..89ab77e 100755
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/ScanToolTest.sh
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/tools/ScanToolTest.sh
@@ -14,8 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-readonly scanner="${TEST_SRCDIR}/copyright/scan_tool"
-readonly testdata="${TEST_SRCDIR}/copyright/src/test/java/com/googlesource/gerrit/plugins/copyright/testdata"
+readonly root=$(dirname "${TEST_BINARY}")
+readonly scanner="${root}/scan_tool"
+readonly testdata="${root}/src/test/java/com/googlesource/gerrit/plugins/copyright/testdata"
 
 function die() {
   echo -e "$@" >&2
diff --git a/tools/android_scan.sh b/tools/android_scan.sh
index 5009332..a3a51b2 100755
--- a/tools/android_scan.sh
+++ b/tools/android_scan.sh
@@ -16,6 +16,7 @@
 
 readonly me=$(basename $0)
 readonly root=$(realpath $(dirname $0)/..)
+readonly build_flags="-c opt"
 
 if [ -z $1 ]; then
   echo >&2
@@ -36,9 +37,9 @@
 
 readonly build_out=$(
   cd "${root}" >&2
-  bazel build -c opt :android_scan >&2
+  bazel build ${build_flags} :android_scan >&2
   echo -n $? " "
-  echo $(bazel info bazel-bin)
+  echo $(bazel info ${build_flags} bazel-bin)
 )
 rc=$(echo ${build_out} | cut -d\  -f1)
 if [ $rc -ne 0 ]; then