Search code examples
clojure

Can I start Gorilla REPL from an uberjar?


I play with this great Gorilla REPL powered project ( https://bitbucket.org/probprog/anglican-examples/ to be specific), and want to use it under certain restricted circumstances.

Is there a way to produce an uberjar that can be started using only a JVM?

Well, I know how to create an uberjar for this project, but can I start a Gorilla REPL from it? If not what do I have to add and how do I start it?

EDITED Note on Juraj's answer:

I added a start file src/gorillaproxy/gorillaproxy.clj with the following content:

(ns gorillaproxy.gorillaproxy
  (:use [gorilla-repl.core :only [run-gorilla-server]])
  (:gen-class))

(defn -main
  [& args]
  (run-gorilla-server {:port 8990}))

Then I added [gorilla-repl "0.4.0"] to the dependency list (in project.clj), and the line

:main gorillaproxy.gorillaproxy

In that way the uberjar started the Gorilla REPL, and when I put the worksheets (and data, resources, .. if needed) into the same directory, everything worked fine.


Solution

  • Gorilla is typically run via the lein-gorilla plugin and thus isn't a part of an uberjar. If you really want to create a bundle containing gorilla repl dependencies, then you need to add it this capability manually to your project.

    The question is why would you want to do that. Do you want to distribute these samples to somebody else? If that's the case, you'll still need to have all those worksheets in the current directory from where your uberjar is run because that's how gorilla repl discovers worksheets.

    You can look at lein-gorilla source code to see how gorilla repl can be started. I'd then at the same code to your project (create new src/core.clj file or whatever) and configure it in your project.clj as :main. You'll also need to add gorilla-repl as a dependency to your project.clj

    Notice however, that you'll need to run that uberjar from a directory where your anglican worksheets are (or a parent directory of such a directory).