John <john.b.ga...@gmail.com> writes:

> Hi,
>
> I am trying to use lein.py, from above, on Windows (Vista).
>
> It works nicely for some commands (e.g. lein.py compile),
> after removing the extra space in two places e.g.
> 'leiningen-%s-standalone .jar' ->
> 'leiningen-%s-standalone.jar'
> and
> '1.1.0-alpha-SNAPSHOT/cloju re-1.1.0-alpha-SNAPSHOT.jar' ->
> '1.1.0-alpha-SNAPSHOT/clojure-1.1.0-alpha-SNAPSHOT.jar'

It's really strange. These additional spaces don't exist in my original script.
They were added by google groups or something.

> But I still have the following error with the 'lein.py install' and
> 'lein.py jar' commands:
>
> E:\temp\leiningen\myproject> E:\etc\clojure\Leiningen\lein.py install
> Exception in thread "main" java.util.regex.PatternSyntaxException:
> Illegal/unsupported escape sequence near index 9
> ^E:\temp\leiningen\myproject
>          ^ (NO_SOURCE_FILE:0)
>         at clojure.lang.Compiler.eval(Compiler.java:5274)
>         at clojure.lang.Compiler.eval(Compiler.java:5226)
> ...
>
> E:\temp\leiningen\myproject> E:\etc\clojure\Leiningen\lein.py jar
> Exception in thread "main" java.util.regex.PatternSyntaxException:
> Illegal/unsupported escape sequence near index 9
> ^E:\temp\leiningen\myproject
>          ^ (NO_SOURCE_FILE:0)
>         at clojure.lang.Compiler.eval(Compiler.java:5274)
>         at clojure.lang.Compiler.eval(Compiler.java:5226)
> ...
>
> I am guessing that this means that the backslash in 'temp\leiningen'
> needs to be escaped
> somewhere in the python script (lein.py) above.
> (I am not clear why the first backslash (in E:\temp) is not reported
> as the error (index 4).)
>
> I have tried many guesses (I am not familiar with python (V2.6)).
> Can anyone make some suggestions?


I don't think it is `lein.py` problem anymore. 
Leiningen uses regular expressions on paths and as usually 
there is a problem with windows path separator.
I took a look in leiningen source and this small patch made
command "jar" working for me on Windows
(I haven't looked at "install" command, but probably it is the same
problem):

<patch>

diff --git a/src/leiningen/jar.clj b/src/leiningen/jar.clj
index 227bccd..d1dd766 100644
--- a/src/leiningen/jar.clj
+++ b/src/leiningen/jar.clj
@@ -22,13 +22,17 @@
                         (str "Main-Class: " main))])
            "\n")))))
 
+(defn unix-path [path]
+  (.replaceAll path "\\\\" "/"))
+
 (defmulti copy-to-jar (fn [project jar-os spec] (:type spec)))
 
 (defmethod copy-to-jar :path [project jar-os spec]
   (doseq [child (file-seq (file (:path spec)))]
     (when-not (.isDirectory child)
-      (let [path (str child)
-            path (re-sub (re-pattern (str "^" (:root project))) "" path)
+      (let [path (unix-path (str child))
+            path (re-sub (re-pattern (str "^" (unix-path (:root project))))
+                         "" path)
             path (re-sub #"^/resources" "" path)
             path (re-sub #"^/classes" "" path)
             path (re-sub #"^/src" "" path)

</patch>


HTH,
Rob

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to