changeset 537:bb15ab8658ab

Add support for 'mvn' and 'ant'.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Mon, 19 Nov 2012 23:59:00 +0200
parents acb751fa8eca
children f57d4fb7d7c5
files misc/mymake.sh
diffstat 1 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/misc/mymake.sh	Mon Nov 19 20:14:06 2012 +0200
+++ b/misc/mymake.sh	Mon Nov 19 23:59:00 2012 +0200
@@ -1,28 +1,37 @@
 #!/bin/bash
 
+shopt -s extglob
+
 opt=
-for arg; do
-  case $opt in
-    f) fname="$arg" ;;
-  esac
-  opt=
-  case "$arg" in
-    -f) opt=f ;;
-  esac
+for (( i=2; i <= ${#@}; i++ )); do
+  if [[ ${@:$i-1:1} = -f ]]; then
+    fname=${@:$i:1}
+    break;
+  fi
 done
 
-if [[ -z "$fname" ]]; then
-  fname=Makefile
-fi
-
 dir="$PWD"
 while [[ -n "$dir" ]]; do
+  cd "$dir"
   if [[ -f "$dir"/"$fname" ]]; then
-    cd "$dir"
+    if [[ $fname == *[mM]ake* ]]; then
+      exec make "$@"
+    else
+      echo "Can't recognise '$fname' type."
+      exit 1
+    fi
+  fi
+  if [[ -f "$dir"/Makefile ]]; then
     exec make "$@"
   fi
+  if [[ -f "$dir"/build.xml ]]; then
+    exec ant -e "$@"
+  fi
+  if [[ -f "$dir"/pom.xml ]]; then
+    exec mvn "$@"
+  fi
   dir=${dir%/*}
 done
 
-echo "'""$fname""'" not found.
+echo "Doesn't found any build scripts."
 exit 1