How to package up a leiningen project for recompilation with all the libraries included? [for users without an internet connection]

StackOverflow https://stackoverflow.com/questions/23405699

I'm giving a Clojure workshop and I want people to be able to modify and recompile the Clojure project. The challenge is that they won't have internet connections - so I need to give them the project and the libraries all at once.

How can I package up a leiningen project for recompilation with all the libraries included?

Assumptions

  • They have leiningen installed on their machine prior to the workshop.

EDIT This is almost the same question as How to package up a maven project for recompilation with all the libraries included? [without an internet connection]

有帮助吗?

解决方案

Move your ~/.m2 directory aside. Run all the lein x leiningen commands you expect your users to have run, also build and test your project (test, install, jar, uberjar, etc.). This will have downloaded (a lot) of dependencies for Leiningen itself as well as for your project. $HOME/.m2 is where you'll find all the jar files that were pulled down by the Maven dependency resolver.

Once you've done this, add :offline? true to the project.clj, According to the documentation, this will Prevent Leiningen from checking the network for dependencies.

See Maven - alternative .m2 directory for an alternative to having to move your .m2 directory aside.

To make using it easy for your students, it may be best to create a self-contained zip archive with the entire .m2 directory, your project and Leiningen itself, along with a basic installer (bash script, or batch file) that moves or symlinks the .m2 directory into the proper place and adds the lein script to the path. This approach should satisfy the off-line needs - I think it covers all of the dependencies you would need.

I have assumed that your students will have java installed and have it on their PATH. Pre-running all of the lein commands you expect to use is important, as some of them have their own dependencies that are only resolved when they are first run.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top