简体   繁体   中英

Check that a Clojurescript jar file is working

I have some Clojurescript source files that output messages to the browser console on a timer. Eventually I would like to make a Clojars library from these files. So far I have created an uberjar using lein. All the user of this library would need to do is :require a namespace from the library, and messages should be emitted to the browser console. Seeing these messages is the "all working fine" test I want to perform.

In other words how do I check that the jar file I have created works? Can I start off with a fresh lein project and just put the jar file in some special 'un-managed' directory and :require the namespace? Actually I don't think you can do such a thing with lein, hence the question.

Assuming you have a project.clj file already with the line

(defproject bigco/biglib "0.1.0-SNAPSHOT”
...

run

lein install

This will build the JAR and install it in your local Maven repo.

Then in your new project, add that dependency and run it.

If your jar (definition of jar includes uberjar of course) does not come neatly from a lein project then an alternative is to use Maven 2 directly:

mvn install:install-file -Dfile=./my-deps.jar -DgroupId=my-deps -DartifactId=my-deps -Dversion=1.0.0 -Dpackaging=jar

Here mvn will store the jar in your local .m2 maven repository. Once stored you can use this jar in any lein project on your machine by referring to it in the dependencies section:

[my-deps "1.0.0"]

Maven documentation for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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