Set up Leiningen on Windows

My first impression for Leiningen is frustration, I simply can not get it right and get it up and running. And I don't want to dig into the source code of the BAT script.

Now I want to to give it another try because I have to build a Clojure project and generate a jar. So I read the BAT script.

The biggest problem of Leiningen is it try to download a file from a BAT script, which is a bad idea.

From the source, the script will 1. concat string to form a url link, something like this

 
https://github.com/downloads/technomancy/leiningen/leiningen-2.7.0-standalone.jar
 

and 2. it will try to download it with wget, curl and powershell and hope any of them works.

There are some serious problems with this approach. User may don't have those tools installed, and even they have, its easy to fail to download the file, for example, wget may fail because the SSL certificate problem. Another problem is the concated url can be wrong or expire, so even you fix the wget problem, you may still can't successfully download the file. You will feel frustrated being stuck there simply because you can not download a file which you know for sure that it did exists somewhere on the internet.

There is also easy way to get it up and running without extra hassles. First get the latest lein.bat from the official site. Find the version from the bat file, it should be on the top of the file and looks like this

 
set LEIN_VERSION=2.7.0
 

Then search "leiningen 2.7.0" or directly go to

 
https://github.com/technomancy/leiningen/releases
 

And download the "leiningen-2.7.0-standalone.zip" from the page with your favorite download tool.

Rename the zip file to "leiningen-2.7.0-SNAPSHOT-standalone.jar" and save to anywhere you likes. For example

 
C:\app\leiningen-2.7.0-SNAPSHOT-standalone.jar
 

Then add a line to your lein.bat right below the LEIN_VERSION line

 
set LEIN_JAR=C:\app\leiningen-2.7.0-SNAPSHOT-standalone.jar
 

Now add the path of lein.bat to your PATH environment variable and you are good to go.