Search code examples
clojureleiningenclojars

Clojure / Leiningen - package jar resource into clojars


I have a question similar to Deploy 3rd-party jar to clojars?

I've pushed a small project into clojars using lein deploy. That project relies on a jar dependency that I've simply put in a folder on the local drive and imported in my :resource-paths as per below:

(defproject cljblpapiwrapper "0.1.0-SNAPSHOT"
  :description ""
  :url ""
  :license {:name "" :url ""}
  :dependencies [[org.clojure/clojure "1.9.0"]]
  :resource-paths ["resources/blpapi-3.8.8-2.jar"]
  :repl-options {:init-ns cljblpapiwrapper.core})

Now upon importing my deployed clojars repo in another project, it fails to find classes within the jar repo. I'm getting this trace:

#error {
 :cause com.bloomberglp.blpapi.CorrelationID
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message java.lang.ClassNotFoundException: com.bloomberglp.blpapi.CorrelationID, compiling:(cljblpapiwrapper/core.clj:6:1)
   :at [clojure.lang.Compiler load Compiler.java 7526]}
  {:type java.lang.ClassNotFoundException
   :message com.bloomberglp.blpapi.CorrelationID
   :at [java.net.URLClassLoader findClass URLClassLoader.java 382]}]
 :trace
 [[java.net.URLClassLoader findClass URLClassLoader.java 382]
  [clojure.lang.DynamicClassLoader findClass DynamicClassLoader.java 69]
  [java.lang.ClassLoader loadClass ClassLoader.java 424]
  [clojure.lang.DynamicClassLoader loadClass DynamicClassLoader.java 77]
  [java.lang.ClassLoader loadClass ClassLoader.java 357]
...

Looks to me like the jar didn't make it to clojars - how can I package it within my repo? Alternatively, how can I push it separately to clojars?

thanks,


Solution

  • Did you try to download your lib from clojars? Use the jar command to unpack the *.jar file and see if the lib is there.

    Look at this repo: https://github.com/cloojure/tupelo-datomic

    In the ./resources dir there is a jar file: datomic-free-0.9.5661-everything.jar

    You may need to play around with the syntax in project.clj to make the uberjar on clojars form correctly. You may need to publish the dependency JAR file on a separate maven-compatible repo. Options include:

    • Deps.co - Created by the host of The REPL podcast
    • AWS S3 - there is a lein plugin to help with this