From 9422fe4b3318b85cdf2f825e712a8559981dd2c8 Mon Sep 17 00:00:00 2001 From: Laurence Hygate Date: Fri, 23 Jul 2010 17:12:39 +0100 Subject: [PATCH] Search parent directories for project.clj if necessary (lein.bat) Deal with cygwin better (lein) --- bin/lein | 24 +++++++++++++----------- bin/lein.bat | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/bin/lein b/bin/lein index 1903cccc..77d6b290 100755 --- a/bin/lein +++ b/bin/lein @@ -2,6 +2,12 @@ VERSION="1.2.0" +# Make sure classpath is in unix format for manipulating, then put +# it back to windows format when we use it +if [ "$OSTYPE" = "cygwin" ]; then + CLASSPATH=`cygpath -up $CLASSPATH` +fi + CLASSPATH="$(ls -1 lib/dev/*jar 2> /dev/null | tr \\n \:)":src/:$CLASSPATH LEIN_JAR="$HOME/.m2/repository/leiningen/leiningen/$VERSION/leiningen-$VERSION-standalone.jar" CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.2.0-beta1/clojure-1.2.0-beta1.jar" @@ -57,15 +63,6 @@ else fi fi -# Convert classpath to Windows format when running on Cygwin -if [ "$OSTYPE" = "cygwin" ]; then - CLASSPATH=`cygpath -wp $CLASSPATH` - CLOJURE_JAR=`cygpath -wp $CLOJURE_JAR` -fi - -if [ $DEBUG ]; then - echo $CLASSPATH -fi HTTP_CLIENT="wget -O" if type -p curl >/dev/null 2>&1; then @@ -108,11 +105,16 @@ elif [ "$1" = "upgrade" ]; then esac fi else - if type -p cygpath >/dev/null 2>&1; then + if [ [$OS_TYPE] = "cygwin"]; then # When running on Cygwin, use Windows-style paths for java CLOJURE_JAR=`cygpath -w "$CLOJURE_JAR"` CLASSPATH=`cygpath -wp "$CLASSPATH"` - NULL_DEVICE=NUL + NULL_DEVICE=NUL + fi + + if [ $DEBUG ]; then + echo $CLASSPATH + echo $CLOJURE_JAR fi if [ "$1" = "repl" ] && [ -z $INSIDE_EMACS ] && [ $TERM != "dumb" ]; then diff --git a/bin/lein.bat b/bin/lein.bat index 65a097b3..69b076ac 100644 --- a/bin/lein.bat +++ b/bin/lein.bat @@ -13,8 +13,8 @@ rem and copied on %CLOJURE_JAR% path rem this step is not necessary, because Leiningen standalone jar rem contains Clojure as well -set CLOJURE_VERSION=1.1.0 -set LEIN_VERSION=1.1.0 +set CLOJURE_VERSION=1.2.0-beta1 +set LEIN_VERSION=1.2.0 rem uncomment this and set paths explicitly rem set LEIN_JAR=C:\Documents and Settings\wojcirob\.m2\repository\leiningen\leiningen\%LEIN_VERSION%\leiningen-%LEIN_VERSION%-standalone.jar @@ -51,6 +51,11 @@ rem ################################################## rem ################################################## rem add jars found under "lib" directory to CLASSPATH rem + +call :FIND_DIR_CONTAINING_UPWARDS project.clj + +if "%DIR_CONTAINING%" neq "" cd "%DIR_CONTAINING%" + setLocal EnableDelayedExpansion set CP=" for /R ./lib %%a in (*.jar) do ( @@ -99,4 +104,34 @@ echo 2. clojure.jar from http://build.clojure.org/releases/ echo. goto EOF +rem Find directory containing filename supplied in first argument +rem looking in current directory, and looking up the parent +rem chain until we find it, or run out +rem returns result in %DIR_CONTAINING% +rem empty string if we don't find it +:FIND_DIR_CONTAINING_UPWARDS +set DIR_CONTAINING=%CD% +set LAST_DIR= + +:LOOK_AGAIN +if "%DIR_CONTAINING%" == "%LAST_DIR%" ( + rem didn't find it + set DIR_CONTAINING= + goto :EOF +) + +if EXIST "%DIR_CONTAINING%\%1" ( + rem found it - use result in DIR_CONTAINING + goto :EOF +) + +set LAST_DIR=%DIR_CONTAINING% +call :GET_PARENT_PATH "%DIR_CONTAINING%\.." +set DIR_CONTAINING=%PARENT_PATH% +goto :LOOK_AGAIN + +:GET_PARENT_PATH +set PARENT_PATH=%~f1 +goto :EOF + :EOF