Leiningen and local repo dependencies issue - clojure

I'm using Leiningen and local repo, and here's my project.clj. Camelclojure is local jar.
(defproject mashup-dsl "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"]
[enlive "1.1.1"]
[ring/ring-core "1.1.8"]
[ring/ring-jetty-adapter "1.1.8"]
[net.cgrand/moustache "1.0.0"]
[ring/ring-devel "1.1.8"]
[compojure "1.1.5"]
[org.clojure/data.zip "0.1.1"]
[org.apache.camel/camel-core "2.11.0"]
[org.apache.camel/camel-component "1.4.0"]
[org.clojure/data.xml "0.0.7"]
[camelclojure "0.0.1-SNAPSHOT"]
]
:repositories {"local" "C:/Users/pvmd/.m2/repository"}
:plugins [[lein-localrepo "0.5.2"]])
I've added a local jar to Maven's repository, but when I run
lein deps
Here's what I get as an error
C:\Users\pvmd\git\mashup-dsl\mashup-dsl>lein deps
Could not transfer artifact camelclojure:camelclojure:pom:0.0.1-SNAPSHOT from/to
local (C:/Users/pvmd/.m2/repository): No connector available to access reposito
ry local (C:/Users/pvmd/.m2/repository) of type default using the available factories FileRepositoryConnectorFactory, WagonRepositoryConnectorFactory
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
I don't use proxy, so its definately a dependency issue, I just can't find the reason why...

Where do you get camelclojure? I didn't find it in MVNRepositories, neither in Clojars. Maybe the project is renamed to something else?
Any way, you should include the groupId also:
[info.kovanovic/camelclojure "0.0.1-SNAPSHOT"]
But still, I would suggest to check the current status of the project. It looks to me that it is renamed.

Related

Adding dependencies to clojure projects using lein

Despite adding the desired dependency to my project.clj file,
(defproject word-tree "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.10.1"]
[org.clojure/clojurescript "1.10.520"]
[clojure-opennlp "0.5.0"] ; <----------------------here
[reagent "0.8.1"]]
...
I am unable to access the functions that the dependency provides.
After referencing the namespace in one of my files,
(ns word-tree.suffix-tree
(:require [clojure.string :as str]
[opennlp.nlp :as nlp])) ; <-----this is the namespace of the dependency
I get this error:
No such namespace: opennlp.nlp, could not locate opennlp/nlp.cljs, opennlp/nlp.cljc, or JavaScript source providing "opennlp.nlp"
The weirdest part is that when I run lein deps :tree the dependency shows up!
$ lein deps :tree
...
[cider/piggieback "0.4.1" :scope "test"]
[cljfmt "0.5.7"]
[rewrite-clj "0.5.2"]
[rewrite-cljs "0.4.3"]
[clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
[clojure-opennlp "0.5.0"] <------------------------------------------------here!!!
[instaparse "1.4.9"]
[org.apache.opennlp/opennlp-tools "1.9.0"]
[figwheel-sidecar "0.5.19" :scope "test"]
...
For my project I really want to use this dependency but it's not working. Any advice would be most welcome. Thanks.
It seems to me the problem is that the library is for Clojure on the JVM only, and you are trying to use it on a ClojureScript project.
No such namespace: opennlp.nlp, could not locate opennlp/nlp.cljs, opennlp/nlp.cljc, or JavaScript source providing "opennlp.nlp"
The compiler tried to look for ClojureScript code (extension .cljs) or compatible with both Clojure and ClojureScript (extension .cljc) or plain JavaScript, but found none.

"'cljsbuild' not a task"

using lein for clojure, attempting to use the clojurescript plugin.
followed all readme.md install steps, project.clj has
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "0.0-3126"]]
;; lein-cljsbuild plugin to build a CLJS project
:plugins [[lein-cljsbuild "1.0.6"]]
:hooks [leiningen.cljsbuild]
I cannot seem to get lein to recognize the plugin and am not sure what is being the gremlin.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein cljsbuild once
'cljsbuild' is not a task. See 'lein help'.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein compile
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein cljsbuild once
'cljsbuild' is not a task. See 'lein help'.
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>lein -v
Leiningen 2.5.1 on Java 1.8.0_51 Java HotSpot(TM) 64-Bit Server VM
C:\Functional_Languages\Clojure\clojurescript_master\!work\modern-cljs>
If you use lein new mies ... for getting the project file, and execute the command, the automatically generated project.clj file should be modified.
This is an example that shows the change:
Before:
(defproject simple "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.122" :classifier "aot"
:exclusion [org.clojure/data.json]]
[org.clojure/data.json "0.2.6" :classifier "aot"]]
:jvm-opts ^:replace ["-Xmx1g" "-server"]
:plugins [[lein-npm "0.6.1"]]
:npm {:dependencies [[source-map-support "0.3.2"]]}
:source-paths ["src" "target/classes"]
:clean-targets ["out" "release"]
:target-path "target")
After
(defproject simple "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.122" :classifier "aot"
:exclusion [org.clojure/data.json]]
[org.clojure/data.json "0.2.6" :classifier "aot"]]
:node-dependencies [[source-map-support "0.2.8"]]
:jvm-opts ^:replace ["-Xmx1g" "-server"]
:plugins [[lein-npm "0.6.1"]
[lein-cljsbuild "1.0.4"]]
:npm {:dependencies [[source-map-support "0.3.2"]]}
:source-paths ["src" "target/classes"]
:clean-targets ["out" "release"]
:target-path "target"
:cljsbuild {
:builds [{:id "simple"
:source-paths ["src"]
:compiler {
:main simple.core
:output-to "out/simple.js"
:output-dir "out"
:optimizations :none
:target :nodejs
:cache-analysis true
:source-map true}}]})
As you see, you need to add lein-cljsbuild plugins with build information. For further explanation, refer to http://www.mase.io/code/clojure/node/2015/01/24/getting-started-with-clojurecript-and-node/
If you don't want the change, just run ./scripts/build.
I think the problem is that your project.clj file is lacking a :cljsbuild stanza/key which defines the various parameters required to compile the clojurescript source files.
Have a look at Modern Clojurescript Tutorial for more details or you can check out my clojurescript file upload example to get an idea of how you can define :cljsbuild targets.

Why does leiningen download 1GB (almost) of jar indexes and how to stop that?

Leiningen downloaded nearly 1GB of jar index information from repo1.maven.org and clojars.org. Why does it need to download that huge amount of information? And is there any way to prevent that?
The directory in question is: ~/.lein/indeces
It contains the following folders:
https___clojars.org_repo_
https___repo1.maven.org_maven2_
The maven.org folder contains 849MB!
Here is my project definition:
(defproject test-project "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"}
:main test-project.core
:dependencies [[org.clojure/clojure "1.6.0"]
[camel-snake-kebab "0.3.1" :exclusions [org.clojure/clojure]]])
Thanks
This content is maintained not by Leiningen itself, but the lein-search plugin. I'd suggest uninstalling it (the plugin, that is) unless you consider its benefits worth the cost in time and storage.
To do so, remove references to lein-search/lein-search or org.clojars.wuschel/lein-search from your ~/.lein/profiles.clj -- or, if this content was created while working in a different project, from the project.clj of that project.

howto package my project resource-paths to use as project dependency?

I'm trying for a while with no success to package as jar file my resource-paths files (.dylib and .so files).
I've packaged the resources folder following this page: How to create jar file with package structure?
and I've installed the jar in my local maven repo following this page http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
I've seen this page how to package resources in a leiningen project also but in this case it seems that the package is not used as clojure dependency in futures projects
This is my project.clj
(defproject quil-video "0.1.0-SNAPSHOT"
:description "extends clojure quil to use video"
: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"]
[quil/quil "2.0.0-SNAPSHOT"]]
:resource-paths ["lib/gstreamer-java.jar" "lib/video.jar" "lib/jna.jar" "lib/macosx64.jar/macosx64"])
And this is the way I'm searching for:
(defproject quil-video-example "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"]
[quil-video/quil-video "0.1.0-SNAPSHOT"]
[quil-video/macosx64 "2"]
[quil-video/jna "1"]
[quil-video/video "1"]
[quil-video/gstreamer-java "1"]])
Thanks in advance!

Using a Clojure/ClojureScript crossover library

I'm working on a library that works with both Clojure and ClojureScript.
Here's the project.clj for the library:
(defproject libtest "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.4.0"]]
:plugins [[lein-cljsbuild "0.3.0"]]
:cljsbuild
{:crossovers [libtest],
:crossover-jar true
:jar true
:builds
[{:source-paths ["src/libtest"], :crossover-path "src/libtest"}]})
I'm including it as a dependency in another project. To get it to work from the ClojureScript side of my project, I had to add the exact namespace as a crossover under the cljsbuild key of my project.clj:
(defproject some-other-project
...
:dependencies [[org.clojure/clojure "1.5.0"]
[libtest "0.1.0-SNAPSHOT"]]
:cljsbuild {
:builds [{
...
:crossovers [libtest.core]
...
My question is, is this necessary? If it's on the classpath, why must I specifically tell it what namespaces I'm going to use? This can't scale well if I need to use dozens of namespaces, some of which will reference other namespaces and etc.
This is not a perfect solution, but works for me. When a namespace is specified as a crossover, its children are added recursively. So :crossovers [libtest] will add libtest.core too. If you specify a :crossover-path, you can see what files are generated into that directory.