talios / clojure-maven-plugin

Apache Maven Mojo for compiling clojure scripts to class files
252 stars 74 forks source link

ClojureSwankMojo.java generates a clojure expression which is wrongly escaped as java string #5

Closed frericksm closed 14 years ago

frericksm commented 15 years ago

Situation:

  1. Using the task clojure:swank i always get an NumberFormatException while clojure is parsing the protocolVersion "2009-09-14".
  2. It seems the that the <"> around the string are vanishing
  3. Looking deeper you find: ClojureSwankMojo generates a clojure expression that is later on consumed by clojure.main as command line argument. Part of this is:
    StringBuilder sb = new StringBuilder();
    sb.append("(do ");
    sb.append("(swank.swank/ignore-protocol-version \"");
    sb.append(protocolVersion);
    sb.append("\") ");
    sb.append("(swank.swank/start-server \"");
    sb.append(swankTempFile.getAbsolutePath());
    sb.append("\" :port ");
    sb.append(Integer.toString(port));
    sb.append(" :dont-close true");
    sb.append("))");

But i should look like this:

    StringBuilder sb = new StringBuilder();
    sb.append("(do ");
    sb.append("(swank.swank/ignore-protocol-version \\\"");
    sb.append(protocolVersion);
    sb.append("\\\") ");
    sb.append("(swank.swank/start-server \\\"");
    sb.append(swankTempFile.getAbsolutePath().replace("\\", "/"));
    sb.append("\\\" :port ");
    sb.append(Integer.toString(port));
    sb.append(" :dont-close true");
    sb.append("))");
  1. The new line

    sb.append(swankTempFile.getAbsolutePath().replace("\\", "/"));

is necessary on windows system, where the temp-File looks like "c:\DOKUME~1\J10839~1.V10\LOKALE~1\Temp\slime.364" with for instance \D gets wrongly interpreted.

talios commented 14 years ago

Just following up on this old old ticket. I've added the replaceAll for \'s to / on windows, but I don't think the escaping is a problem ( no one else has mentioned that - and we've also since removed the call to protocolVersion ).