简体   繁体   English

我可以从uberjar启动Gorilla REPL吗?

[英]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. 我参与了这个由Gorilla REPL支持的出色项目(具体来说https://bitbucket.org/probprog/anglican-examples/ ),并希望在某些受限情况下使用它。

Is there a way to produce an uberjar that can be started using only a JVM? 有没有一种方法可以生成只能使用JVM启动的uberjar?

Well, I know how to create an uberjar for this project, but can I start a Gorilla REPL from it? 好吧,我知道如何为该项目创建uberjar,但是我可以从中启动Gorilla REPL吗? If not what do I have to add and how do I start it? 如果不是,我必须添加什么以及如何开始?

EDITED Note on Juraj's answer: 关于Juraj答案的编辑说明:

I added a start file src/gorillaproxy/gorillaproxy.clj with the following content: 我添加了一个具有以下内容的开始文件src / gorillaproxy / gorillaproxy.clj:

(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 然后,我将[gorilla-repl“ 0.4.0”]添加到依赖项列表中(在project.clj中),并且该行

: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. 这样,uberjar启动了Gorilla REPL,并且当我将工作表(以及数据,资源,如果需要)放在同一目录中时,一切工作正常。

Gorilla is typically run via the lein-gorilla plugin and thus isn't a part of an uberjar. 大猩猩通常通过lein-gorilla插件运行,因此不是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. 如果您确实要创建一个包含大猩猩repl依赖项的捆绑软件,则需要将此功能手动添加到您的项目中。

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 . 如果是这样,您仍然需要将所有这些工作表放在运行uberjar的当前目录中,因为这是gorilla repl发现工作表的方式

You can look at lein-gorilla source code to see how gorilla repl can be started. 您可以查看lein-gorilla源代码以了解如何启动gorilla repl。 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 . 然后,我将对您的项目使用相同的代码(创建新的src/core.clj文件或其他内容),然后在project.clj中将其配置为:main You'll also need to add gorilla-repl as a dependency to your project.clj 您还需要gorilla-repl作为依赖项添加到您的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). 但是请注意,您需要从英国国教工作表所在的目录(或此类目录的父目录)中运行该uberjar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM