Search code examples
clojureleiningen

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.

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.

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. I've tried making a .jar file with a Manifest.txt giving it version 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.

The project.clj file is like this:

  :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!


Solution

  • The updated project.clj file after the helpful comment by leetwinski:

      :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"]}})