Using particular clojure java-wrapper with no project.clj

330 views Asked by At

I try to avoid asking questions that won't help many other people, but I've been at this for far too long to not ask for help. I'm trying to use this clojure wrapper for a java package as a dependency in my project, but I'm hitting a lot of errors because there's no project.clj.

I've tried using the lein-git-deps plugin with the following keys in my project.clj:

:plugins [[lein-git-deps "0.0.1-SNAPSHOT"]]
:git-dependencies [["https://github.com/lunkdjedi/clj-ta-lib"]]

Running $ lein git-deps gives me the following:

Setting up dependency for  [https://github.com/lunkdjedi/clj-ta-lib]
Running git pull on  .lein-git-deps
Running git checkout  master  in  .lein-git-deps

but nothing changes in my local directory, except now there's an empty .lein-git-deps/ dir. I'm assuming this didn't work because of the missing project.clj.

I've been able to clone the project and call $ mvn package clojure:repl which successfully compiled and opened a REPL instance, in which I could use the wrapper perfectly. When I run $ lein install it gives me:

Couldn't find project.clj, which is needed for install

but when I run $ mvn install it gives me a BUILD SUCCESS and can be found in ~/.m2/repositories/clj-ta-lib.

I put :dependencies [[clj-ta-lib/clj-ta-lib "0.0.1"]] in my project.clj and restart the REPL but when I call (use 'clj-ta-lib.core) I get:

CompilerException java.lang.Exception: namespace 'clj-ta-lib.core' not found, compiling:(*cider-repl app*:71:13) 

Edit:

No longer getting the previous error, but still getting this one:

CompilerException java.lang.IllegalArgumentException: No matching ctor found for class com.tictactec.ta.lib.meta.PriceHolder, compiling:(clj_ta_lib/core.clj:13:3) 
2

There are 2 answers

3
amalloy On BEST ANSWER

The stuff you say you've done sounds pretty reasonable. It's a shame the project isn't hosted on clojars or on maven central, but at least there's a pom to allow you to publish or install it easily yourself. mvn install is the right thing to do, and when I clone the project myself and install it, everything installs fine just as you say it does.

However, I can't reproduce your error when trying to use the library. After installing it, I created a new project that depends on the just-installed artifact, and in a repl inside that project, I can use the library's classes just fine. Or, well, I don't know how to use these functions as intended, but the functions are available for my use:

user=> (use 'clj-ta-lib.core)
nil
user=> ta
#<core$ta clj_ta_lib.core$ta@c668834>

So I'd say, make sure you really did follow all the steps you say you did, and that your repl has been started cleanly inside of the project that depends on your library.

1
Saikat Kumar Dey On

As mentioned here, https://mvnrepository.com/artifact/com.tictactec/ta-lib/0.4.0 just add [com.tictactec/ta-lib "0.4.0"] to the dependencies in your project.clj.

:dependencies [[com.tictactec/ta-lib "0.4.0"]]