سؤال

I have a basic question regarding deployment to Clojars. I wrote a library and deployed it to Clojars, but when I try to require it, I receive a java.lang.ClassNotFoundException.

Here is how I am requiring it:

https://github.com/mobiusinversion/interval-trees

and here is where it is on Clojars:

https://clojars.org/interval-trees

I think maybe I am missing something with respect to group or artifact ids, I'm not sure. I would appreciate help in having this go out. Thanks!

The way I am testing this is in a new lein project called interval-tree-test. Here is my project.clj for that test:

(defproject interval-tree-test "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
        :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [interval-trees "0.2.3"]]
  :main interval-tree-test.core)

Now when I run lein deps I get

$ lein deps
Retrieving interval-trees/interval-trees/0.2.3/interval-trees-0.2.3.pom from clojars
Retrieving interval-trees/interval-trees/0.2.3/interval-trees-0.2.3.jar from clojars

And sure enough in my .m2 directory

$ ls ~/.m2/repository/interval-trees/interval-trees/0.2.3/  
interval-trees-0.2.3.jar.sha1    interval-trees-0.2.3.pom.sha1
interval-trees-0.2.3.jar         interval-trees-0.2.3.pom

And finally in my core.clj

(ns interval-tree-test.core
    (:gen-class)
    (:require [interval-trees.interval-tree :as it]))

    (defn -main [& args] )
هل كانت مفيدة؟

المحلول

Your require form is wrong. There are two ways to solve this:

  • You can move the :require form into the ns form:

    (ns interval-tree-test.core
      (:require [interval-trees.interval-tree :as it])))
    
  • You can use the require function to do it without a ns form:

    (require '[interval-trees.interval-tree :as it])) ;; note the quote
    

I don't know why/how using :gen-class would have helped you fix that, though.

نصائح أخرى

I sprinkled :gen-class in all my .clj in interval-trees and it worked. Dont get it but glad its done.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top