Leiningen 2 does not look in localrepo? - clojure

I'm using Leiningen 2 and am struggling to get it to recognize the local repository ($HOME/.m2)
I'm trying to use the storm-rdbms(storm-contrib) which is not on clojar
Here are the steps I've taken:
Using the lein-localrepo plugin, installed storm-rdbms under the .m2 local repository
The pom.xml shows this:
<groupId>storm-rdbms</groupId>
<artifactId>storm-rdbms</artifactId>
<versioning>
<versions>
<version>0.1-SNAPSHOT</version>
</versions>
<lastUpdated>20130214173431</lastUpdated>
</versioning>
my project.clj file :
:dependencies [[org.clojure/clojure "1.4.0"]
[storm "0.8.2"]
[storm-rdbms "0.1-SNAPSHOT"]]
:plugins [[lein-localrepo "0.4.1"]]
:repositories {"local" ~(str (.toURI (java.io.File. "~/.m2")))})
I run lein deps:
Could not find artifact storm-rdbms:storm-rdbms:jar:0.1-SNAPSHOT
This could be due to a typo in :dependencies or network issues.
Could not resolve dependencies
I've tried this with Maven as well, but Maven 3 is not even able to install the jar when following the directions from here.
Please shed some light on what I'm doing wrong here. Thanks so much!

when you run mvn install, storm-rdbms seems not to ?properly? install a pom when it installs the jar, which was preventing lein from finding it.
here are the full steps I used:
git clone git://github.com/nathanmarz/storm-contrib.git
cd storm-contrib/storm-rdbms/
mvn install
cp pom.xml ~/.m2/repository/storm/storm-rdbms/0.1-SNAPSHOT/storm-rdbms.pom
cd ~/my-storm-project
emacs project.clj and add this dep:
[storm/storm-rdbms "0.1-SNAPSHOT"]
lein deps
I'm not sure if this is because it's a sub project. I was unable to build the parent project because one of the other sub-projects was broken when I checked it out...

Related

How do I create a Clojure application with lein uberjar if I have a dependency in checkouts?

I have a Clojure application that is using a library which is symlinked from inside the "checkouts" directory.
This lets me work on both the app and the library at the same time. And lein knows how to compile and run the program without any problems.
But I want to make a standalone with lein uberjar, and it's complaining
Caused by: java.io.FileNotFoundException: Could not locate mylib/core__init.class, mylib/core.clj or mylib/core.cljc on classpath.
I assume that that is because mylib isn't mentioned in my project.clj file. It isn't, precisely because I want to use the version of mylib symlinked inside "checkouts".
But the uberjar command doesn't seem to be able to see it.
How can I solve this?
You can accomplish this by installing mylib in your local repository (~/.m2/repository).
Run lein install in the dependent project to install it in your local repository.
Add the project to :dependencies: in project.clj:
[mylib "version"]
Run lein uberjar in the main project.
The project will find the jar in your local repository.
/Edit
If you want to develop two libraries at the same time you can use a checkouts folder where checkouts contains a symlink to the dependent library.
mkdir checkouts
ln -nfs full-path-other-lib-dir full-path-checkouts-dir
Now changes in other-lib are immediately available in the main project.
See [https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies](the Leiningen checkouts documentation).
OK, it appears that the "checkouts" feature of lein works with lein test and lein run but not with lein uberjar.
I added the following to the local source code of a lib tupelo.core:
(def dummy-sample-data "Bogus!")
In the consuming project demo.core we can access the new Var:
(ns demo.core
(:use tupelo.core tupelo.test))
(defn -main [& args]
(println :foo-enter)
(spyx dummy-sample-data)
(println :foo-leave))
lein run produces:
:foo-enter
dummy-sample-data => "Bogus!"
:foo-leave
project.clj remains unchanged:
(defproject demo "0.1.0-SNAPSHOT"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [
[criterium "0.4.5"]
[org.clojure/math.combinatorics "0.1.6"]
[org.clojure/clojure "1.10.1"]
[prismatic/schema "1.1.12"]
[tupelo "0.9.201"]
<snip>
where "0.9.201" is the latest version of tupelo on Clojars. Checkouts looks like:
~/expr/demo > ls -ldF checkouts/*
lrwxrwxrwx 1 alan alan 17 May 12 13:57 checkouts/tupelo -> /home/alan/tupelo/
but uberjar fails:
~/expr/demo > lein clean ; lein uberjar
Compiling demo.core
Syntax error compiling at (demo/core.clj:6:3).
Syntax error compiling at (demo/core.clj:6:3).
Unable to resolve symbol: dummy-sample-data in this context
Full report at:
/tmp/clojure-10416346559924917196.edn
Compilation failed: Subprocess failed
Options
If you are wanting to deploy an application, you have 2 options:
If the lib exists on Clojars or Maven, you should probably deploy a release there before making a uberjar. If the lib is not ready for Clojars or Maven, maybe you aren't ready to use it in a uberjar...?
Simply copy the source tree of mylib (or use a symlink!) under the ./src dir in your project. You'll also have to copy in the dependencies into myproj/project.clj. You are effectively merging myproj and mylib, at least temporarily with this approach. If the are coupled tightly enough to require co-development, perhaps it should be a permanent merge?

Enlive Tutorial Issues

This is a case of a failure to launch. Namely I am attempting to work through the Enlive tutorial, but have run into the following issue of FileNotFoundException while typing (load "tutorial/scrape1") into the REPL.
I am using the following dependencies
:dependencies [[org.clojure/clojure "1.5.1"]
[enlive "1.1.1"]]
I do the classic steps of lein deps then open the REPL and typing the aforementioned line as the tutorial asks. This is all part of the "Your First Scrape with Enlive..." section of https://github.com/swannodette/enlive-tutorial
Well that are not the only dependencies you need to add to your project.clj. This file needs to look like:
(defproject enlive-tutorial "0.1.0"
:description "Enlive Tutorial"
:dependencies [[org.clojure/clojure "1.5.1"]
[enlive "1.1.1"]
[ring "1.2.0"]
[net.cgrand/moustache "1.1.0"]])
So running lein deps will cause in a long term of downloading dependencies. After this you can just start with the tutorial as presented in the link you just posted.
Maybe it is a good idea just to clone the git repository and follow the instructions they give you to start coding with it:
1. git clone git://github.com/swannodette/enlive-tutorial.git
2. cd enlive-tutorial
3. lein deps
4. lein repl

How to use current builds of rxjava in clojure with leiningen

I want to use some of the latest features being built frequently at https://github.com/Netflix/RxJava in Clojure, but am having some difficulties getting Leiningen to reference the local .jar that I build. The last version of rxjava released to Clojars was 0.9.0, which I can successfully reach with the following in my projects.clj
:dependencies [[org.clojure/clojure "1.5.1"]
[com.netflix.rxjava/rxjava-clojure "0.9.0"]]
Now, I do a successful build of the current rxjava sources, which produces the following files
/Users/rebcabin/Documents/RxJava/language-adaptors/rxjava-clojure/build/libs/rxjava-clojure-0.9.1-SNAPSHOT-javadoc.jar
/Users/rebcabin/Documents/RxJava/language-adaptors/rxjava-clojure/build/libs/rxjava-clojure-0.9.1-SNAPSHOT-sources.jar
/Users/rebcabin/Documents/RxJava/language-adaptors/rxjava-clojure/build/libs/rxjava-clojure-0.9.1-SNAPSHOT.jar
In my Clojure project directory, I do the following
mvn deploy:deploy-file \
-DgroupId=local \
-DartifactId=rxjava-clojure \
-Dversion=0.9.1-SNAPSHOT \
-Dpackaging=jar \
-Dfile=/Users/rebcabin/Documents/RxJava/language-adaptors/rxjava-clojure/build/libs/rxjava-clojure-0.9.1-SNAPSHOT.jar \
-Durl=file:maven_repository
following the instructions given here: https://gist.github.com/stuartsierra/3062743 (see the bottom) via http://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/ and leiningen - how to add dependencies for local jars?.
That reports success and produces the following:
$ find maven_repository/
maven_repository/
maven_repository//local
maven_repository//local/rxjava-clojure
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/maven-metadata.xml
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/maven-metadata.xml.md5
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/maven-metadata.xml.sha1
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/rxjava-clojure-0.9.1-20130628.172154-1.jar
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/rxjava-clojure-0.9.1-20130628.172154-1.jar.md5
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/rxjava-clojure-0.9.1-20130628.172154-1.jar.sha1
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/rxjava-clojure-0.9.1-20130628.172154-1.pom
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/rxjava-clojure-0.9.1-20130628.172154-1.pom.md5
maven_repository//local/rxjava-clojure/0.9.1-SNAPSHOT/rxjava-clojure-0.9.1-20130628.172154-1.pom.sha1
maven_repository//local/rxjava-clojure/maven-metadata.xml
maven_repository//local/rxjava-clojure/maven-metadata.xml.md5
maven_repository//local/rxjava-clojure/maven-metadata.xml.sha1
I now fix my projects.clj file to contain the following:
:dependencies [[org.clojure/clojure "1.5.1"]
[com.netflix.rxjava/rxjava-clojure "0.9.1"]]
:repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}
but lein deps fails to find the local repo
$ lein deps
Could not find artifact com.netflix.rxjava:rxjava-clojure:jar:0.9.1 in central (http://repo1.maven.org/maven2/)
Could not find artifact com.netflix.rxjava:rxjava-clojure:jar:0.9.1 in clojars (https://clojars.org/repo/)
Could not find artifact com.netflix.rxjava:rxjava-clojure:jar:0.9.1 in local (file:/Users/rebcabin/Documents/ClojureProjects/rxjava/expt1/maven_repository/)
This could be due to a typo in :dependencies or network issues.
The following guesses in project.clj also do not work:
:dependencies [[org.clojure/clojure "1.5.1"]
[com.netflix.rxjava/rxjava-clojure "0.9.1-SNAPSHOT"]]
:repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}
:dependencies [[org.clojure/clojure "1.5.1"]
[com.netflix.rxjava/rxjava-clojure "0.9.1--20130628.172154-1"]]
:repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}
any ideas how to proceed, please & thanks?
(I also answered on the mailing list where you asked this)
The groupId in your deploy-file command is incorrect. It should be com.netflix.rxjava. Then in your project.clj, use [com.netflix.rxjava/rxjava-clojure "0.9.1-SNAPSHOT"] for your dependency. Also note that you'll need to do the same with rxjava.core.
from the rxjava project directory run
mvn install
to install the jars to your system's local maven repo.
from your Clojure project's directory add 0.9.1-SNAPSHOT as a dependency and then
lein deps :tree
and make sure you see the correct version used.

Clojure & ZeroMQ

Can anyone tell me some working dependencies to get up and running with zeromq and clojure?
I've tried several but leiningen isn't able to fetch them:
(Could not find artifact org.zmq:zmq:jar:2.1.0 in central (http://repo1.maven.org/maven2))
[org.zmq/zmq "2.1.0"]
[org.zmq/jzmq "1.0.0"]
I have compiled jzmq (/usr/local/share/java/jzmq.jar) and added this to my project.clj:
:native-path "/usr/local/lib"
There's a 2.0-SNAPSHOT here:
Lein should already have the clojars repo loaded.
What I propose is a mixture of what's already been proposed, but for the sake of completeness and hopefully to give a final answer I give it a try.
Since the dependency is not in the online repos I would include the jar(s) in the project's directory structure itself, e.g. in the directory repository and keep it in the source control system as the other files of the project. It's an important part of the project and without the dependency it won't run.
In this directory I would save the jar with the help of Maven Install plugin.
mvn install:install-file \
-Dfile=/usr/local/share/java/jzmq.jar \
-DgroupId=org.zeromq \
-DartifactId=jzmq \
-Dversion=2.1.0 \
-Dpackaging=jar \
-DlocalRepositoryPath=repository
When the jar file gets copied to the local repository, you define it and the dependency in project.clj as follows:
(defproject clojure-interal-repo-test "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.4.0"]
[org.zeromq/jzmq "2.1.0"]]
:repositories [["zeromq-repository" {:url "file:repository"
:snapshots false
:checksum :ignore
:update :never}]])
Within the project, run lein2 deps :tree to verify its correctness.
$ lein2 deps :tree
Retrieving org/zeromq/jzmq/2.1.0/jzmq-2.1.0.jar (4k) from file:repository/
[org.clojure/clojure "1.4.0"]
[org.zeromq/jzmq "2.1.0"]
Please note that the 4k above is the size of a fake file I created to test it out.
Read the document Repeatability in Leiningen's wiki should you need a bit more.
The only way I could get it to work was to use jeromq.
[org.zeromq/jeromq "0.3.2"]
Jeromq is native Java.
You can create a Maven local repository, install the compiled library into your local repo, and then, add the following to your project.clj
:repositories {"local" ~(str (.toURI (java.io.File. "your_local_repository_path")))}
Similar question, I have answered earlier here
Unfortunately, ZeroMQ is not present in public repository, at least at the last time I checked (a month ago I think). So you have to install the jar manually:
mvn install:install-file -Dfile=/usr/local/share/java/jzmq.jar -DgroupId=org.zeromq \
-DartifactId=jzmq -Dversion=2.1.0 -Dpackaging=jar
Then you can use the artifact as [org.zeromq/jzmq "2.1.0"] in your project.clj.

clojure lein: How do I include source from another directory in my project?

I have a lein project in one directory, and instead of using the .jar that gets downloaded when I run
> lein deps
I want to use the source from a cloned github repository (It has recent fixes not in the current jar). What is the canonical way to do this with leiningen?
Here is my project file:
(defproject oroboros "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]
[clojure-source "1.2.1"]
[overtone "0.3.0"]
[penumbra "0.6.0-SNAPSHOT"]]
:native-dependencies [[penumbra/lwjgl "2.4.2"]]
:dev-dependencies [[native-deps "1.0.5"]
[swank-clojure "1.4.0-SNAPSHOT"]])
I want to use the overtone repo from github, rather than the one from clojars.
https://github.com/overtone/overtone
Is this possible?
You can use checkout dependencies. From Leiningen's README:
Q: I want to hack two projects in parallel, but it's annoying to
switch between them.
A: Use a feature called checkout dependencies. If you create a
directory called checkouts in your project root and symlink some other
project roots into it, Leiningen will allow you to hack on them in
parallel. That means changes in the dependency will be visible in the
main project without having to go through the whole
install/switch-projects/deps/restart-repl cycle. Note that this is not
a replacement for listing the project in :dependencies; it simply
supplements that for tighter change cycles.
Back when I was using lein I simply put symlinks in my project directory to the checked out Overtone source dir.
I use cake for my Overtone hacking these days which has support for adding external projects to the class path. You just need to add the path to project.classpath in your project's .cake/config file:
project.classpath = /Users/sam/Development/improcess/lib/overtone/src: