Skip to content

timgilbert/lein-classpath-jar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lein-classpath-jar

A Leiningen plugin to work around long-classpath issues on Windows.

Clojars Project

Background

Most Clojure tooling, including lein, run programs by constructing a big classpath out of the dependency tree and then passing that as a command-line argument to java.

On Windows this can be problematic when the classpath is very long, since the length of Windows command-line arguments is extremely constrained when compare to most Unix-based OSes. Depending on various factors, the maximum length can range from 8191 characters to 32K characters, but even 32K may not be enough for some applications with a large dependency tree.

The symptom of this is usually that you'll get an exception from running lein repl that resembles this:

Exception in thread "Thread-2" java.io.IOException: Cannot run program "java" (in directory "C:\Users\tim\blah"): CreateProcess error=206, The filename or extension is too long
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        [...]
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
        at java.lang.ProcessImpl.create(Native Method)
        [...]

The usual solution to this problem for JVM-based Windows development is to create a "pathing jar" - that is, a jar which only contains a Manifest that points to the various jar files that make up the entire classpath of the program. Java can then be invoked via java -cp pathing.jar clojure.main and the resulting JVM will have the proper classpath.

More information can be found in the tools.deps ticket TDEPS-120.

What this plugin does

This leiningen plugin borrows an idea from tools.deps.alpha - whenever a classpath is generated by leiningen, we compute its MD5 hash and generate a pathing jar file based on that hash. Then we return the location of the jar file, rather than the concatenated list of every jar file actually on the path.

As a bonus, the generated files are compatible with the Windows tools.deps implementation.

Usage

This is intended to work as a user-level plugin. To use it, add this to the :plugins vector of your :user profile:

{:user {:plugins [[lein-classpath-jar "0.1.0"]]}}

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A plugin to work around Windows classpath limits for leiningen

Resources

License

Stars

Watchers

Forks

Packages

No packages published