简体   繁体   English

Clojure with Leiningen:如何包含本地依赖项?

[英]Clojure with Leiningen: how to get local dependencies included?

I am working on learning Clojure through the Programming Clojure book but stuck early trying to get an example from the book working.我正在通过《 Clojure 编程》一书学习 Clojure,但很早就试图从书中获取示例。

I downloaded the code examples from the book;我从书中下载了代码示例; the directory structure is目录结构是

examples/

and there are a bunch of .clj files in there including one called introduction.clj .并且里面还有一堆.clj的文件,包括一个叫introduction.clj。

The code I'm trying to run starts with我试图运行的代码开始于

(require 'examples/introduction')

... but I can't get this to work. ......但我无法让它发挥作用。

I've tried adding a checkouts directory and symlinking the examples directory in there.我已经尝试添加一个checkouts目录并符号链接其中的示例目录。 I've tried making a .jar file with a Manifest.txt giving it version 1.0.0 ....我试过用 Manifest.txt 制作一个 .jar 文件,给它版本 1.0.0 ....

But running但是跑步

lein repl

so far always gives errors, like到目前为止总是给出错误,比如

Could not find artifact examples:introduction:jar:1.0.0 in central ( https://repo1.maven.org/maven2/ ) Could not find artifact examples:introduction:jar:1.0.0 in clojars ( https://repo.clojars.org/ ) This could be due to a typo in :dependencies, file system permissions, or network issues.在中央( https://repo1.maven.org/maven2/ )找不到工件示例:介绍:jar:1.0.0 在clojars( https://repo )中找不到工件示例:介绍:jar:1.0.0 .clojars.org/ ) 这可能是由于:依赖项、文件系统权限或网络问题中的拼写错误。

The project.clj file is like this: project.clj文件是这样的:

  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [clj-http "2.0.0"]
         [examples/introduction "1.0.0"]]
  :main ^:skip-aot my-stuff.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all
                       :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})

What am I missing?我错过了什么? Thanks much for any guidance whatsoever!非常感谢您的任何指导!

The updated project.clj file after the helpful comment by leetwinski:在 leetwinski 的有用评论之后更新的 project.clj 文件:

  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [clj-http "2.0.0"]]
  :source-paths ["/home/mark/src/cloj/code/src/examples"]
  :main ^:skip-aot my-stuff.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all
                       :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})

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

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