I'm having difficulty referencing classes generated via :gen-class.
The smallest example I can show that demonstrates the problem is:
(defproject test-proj
:dependencies [[org.clojure/clojure "1.8.0"]]
:aot [test-proj.test])
(ns test-proj.test
(:gen-class))
(defn -main []
(println test_proj.test)) ; Error here
The problem is, this yields a ClassNotFoundException on the marked line.
(I tried all different combinations of - and _ in the above file and the project.clj. I still don't fully understand what requires an underscore and what tolerates a dash. Some things seem to roll with dashes and convert them as needed, whereas I know from messing around that in the -main, I need underscores to reference test_proj.test.)
If I go into the project root file, there's no target folder, so it's not generating the class. If I go into the terminal and run lein compile, it generates the needed classes under target, and the above code runs without error. This is a poor workaround though. What if I modify the file and forget to manually recompile it? It's also a pain to have to manually compile it after any time I do a clean.
As a shot in the dark, I tried using compile right underneath the ns macro:
(compile 'test-proj.test)
If I uses dashes, compile seems to do literally nothing. I may be misinterpreting its use, but it doesn't generate class files under target. If I use underscores, it gives an exception saying that the namespace isn't found.
Is there a way to have the classes generated automatically so I don't need to run lein compile everytime? I thought that that's what the :aot in the project.clj did.
With Leiningen, specify :aot settings. :all is the easiest.
project.clj
(defproject test-proj "0.1.0-SNAPSHOT"
:main test-proj.core
:aot :all
:dependencies [[org.clojure/clojure "1.8.0"]])
If you want, you can specify the exact namespaces in an array as seen below:
project.clj
(defproject test-proj "0.1.0-SNAPSHOT"
:main test-proj.core
:aot [test-proj.core]
:dependencies [[org.clojure/clojure "1.8.0"]])
Then the following lein command:
lein compile
Will generate the byte code and .class files as specified in the :aot settings above.
core.clj
(ns test-proj.core
(:gen-class))
(defn -main[]
(println test_proj.core)
(println "Hello, World!"))
You want to see something like the below:
NikoMacBook% lein compile
Compiling test-proj.core
Once this is done, check the target folder, contains the proper class file, here test_proj/core.class.
NikoMacBook% tree target
target
├── classes
│ ├── META-INF
│ │ └── maven
│ │ └── test-proj
│ │ └── test-proj
│ │ └── pom.properties
│ └── test_proj
│ ├── core$_main.class
│ ├── core$fn__38.class
│ ├── core$loading__5569__auto____36.class
│ ├── core.class
│ └── core__init.class
└── stale
└── leiningen.core.classpath.extract-native-dependencies
7 directories, 7 files
The following will run the :main namespace, so test-proj.core.
lein run
Will output
NikoMacBook% lein run
Compiling test-proj.core
Compiling test-proj.core
test_proj.core
Hello, World!
Note, that the class is calling itself. Note also that if you do not run lein compile beforehand , it will run by itself.
Related
I have checked the referenced questions, and I am still puzzled. I have some tests that work in CIDER in emacs, but not via lein test. I need to make them work in lein test.
I have the following source layout in a Clojure project:
ClojureProjects002/asr (master ✖ ✹ ✭)──>
tree src
src
├── asr
│ ├── arithmetic.clj
│ ├── asr.clj
... many files ...
│ ├── core.clj <~~~~~~~ notice this one
... more files ...
│ └── utils.clj
└── stack_machine <~~~~~~~ notice underscore
└── stack.clj
5 directories, 23 files
ClojureProjects002/asr (master ✖ ✹ ✭)──>
tree test
test
├── asr
│ └── core_test.clj <~~~~~~~ this one works in lein
└── stack_machine <~~~~~~~ this one doesn't
└── sm_test.clj <~~~~~~~ notice underscores
The files src/stack_machine/stack.clj and test/stack_machine/sm_test.clj follow here:
stack.clj:
(ns stack-machine.stack ;; <~~~~~~~ notice dash
(:import java.util.concurrent.Executors))
;;; blah blah blah
(def thread-pool
(Executors/newFixedThreadPool
(+ 2 (.availableProcessors (Runtime/getRuntime)))))
;;; blah blah blah
sm_test.clj:
(ns sm-test ;; <~~~~~~~ notice dashes here
(:use [stack-machine.stack]) ;; ~~~~ and here
(:require [clojure.test :as t]))
(t/deftest test-test-itself
(t/testing "tests in the namespace 'stack machine.'"
(t/is (== 1 1.0))))
The test file works in CIDER when I do cider-test-run-ns-tests, but lein test produces the following error (gist: can't find sm_test.clj)
(it does the tests on asr namespace, then)
Execution error (FileNotFoundException) at user/eval227 (form-init3759808036021590492.clj:1).
Could not locate sm_test__init.class, sm_test.clj or sm_test.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
How can I make lein test work for this entire project?
I'd be grateful for any advice!
I am surprised that CIDER found the test, since the namespace in sm_test is wrong. It should be:
(ns stack-machine.sm-test ; added `stack-machine`
(:use stack-machine.stack clojure.test)) ; removed unneed square brackets
(deftest test-test-itself
(testing "tests in the namespace 'stack-machine.'"
(is (= 5 (+ 2 3))))) ; avoid int vs float comparisons!
P.S. It would be better to maintain symmetry between the names of the source & test file, eg:
src/stack_machine/stack.clj
test/stack_machine/stack_test.clj
P.S. I try to avoid using hyphens in a namespace so you don't have to translate to underscores in the file name & vice versa.
I built my project using lein new app hello, so I have this structure
.
└── src
└── hello
└── core.clj
└── project.clj
└── test
└── ..
I want to add another helper module to my project such that I can use the code in both the tests and the src modules as I wanted it decoupled from the src directory.
So I added a helpers module
.
└── src
└── hello
└── core.clj
└── project.clj
└── test
└── helpers
└──hello
└── helpers.clj
How can I change my project.clj file to make lein run compile. lein run does not compile and throws the following error when I try to require the helpers namespace.
Exception in thread "main" java.lang.ClassNotFoundException:
hello.helpers, compiling:(hello/core.clj:7:3)
My project.clj file looks like the default one :
(defproject hello "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.8.0"]]
:main ^:skip-aot hello.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
However in the IDE(IntelliJ) it works fine in the REPL, without throwing the class not found exception.
Add
:source-paths ["src" "helpers"]
to your project.clj file.
tl;dr: Unexpected layout of .class files produced by clojure compiler invoked from scala code.
I have an SBT project (using playframework) that includes some clojure code. The clojure compiler is being called from an SBT task in the build.sbt file. Here is the scala code invoking the clojure compiler(credit to: sbt-clojure).
The compiler is outputting .class files, but not in the layout I expect( based on the ns definition).
If I define my clojure namespace as follows:
(ns api.datastore.foo
(:require [clojure.core.async :refer (<!!)]
[datomic.client :as client])
(:gen-class
:methods [#^{:static true} [bar [java.util.List] clojure.lang.ISeq]])
... and this clojure source is located in app/api/datastore, then the layout of files resulting from clojure compilation is this:
└── classes
├── foo__init.class
└── api
└── datastore
├── foo.class
├── foo$fn__3.class
├── foo$loading__5569__auto____1.class
└── foo$_bar.class
When I try to call any of this code (e.g. function bar), an error results:
...java.io.FileNotFoundException: Could not locate api/datastore/foo__init.class or api/datastore/foo.clj on classpath...
Changing the definition of my namespace (note :name key) to this:
(ns foo
(:require [clojure.core.async :refer (<!!)]
[datomic.client :as client])
(:gen-class
:name api.datastore.foo
:methods [#^{:static true} [bar [java.util.List] clojure.lang.ISeq]])
... and moving this clojure source to app/ produces output like this:
└── classes
├── foo__init.class
├── foo$fn__3.class
├── foo$loading__5569__auto____1.class
├── foo$_bar.class
└── api
└── datastore
└── foo.class
... and it works!
But, now I don't have any directory structure for my clojure sources(the all have to be in app/), which is a problem for a number of reasons. Is there anyway to do this without the :name key(i.e. get the target directory structure that works from the namespace definition that doesn't)?
I'm having problems using a local version of a library which I don't want to push up to Clojars to test and find out it's broken. I appreciate this is a common problem for lots of devs new to Clojure and Leiningen. I've followed the steps provided by others and it still doesn't work.
In summary:
I've tried lein pom/jar/install, as well as the checkout feature (where you symlink your other project). I think there is a source-paths option I could try, but I'm not sure how that works. I also thought about trying to modify the lein classpath but I'm not sure if that's possible?
For those of you who prefer much more detail...
I have two Leiningen projects:
https://github.com/Integralist/spurious-clojure-aws-sdk-helper
https://github.com/Integralist/spurious-clojure-example
The idea is that the second project "spurious-clojure-example" should use the first "spurious-clojure-aws-sdk-helper" as a dev dependency (as it's a library you use while local dev'ing against faked AWS resources; so no need to use it in a production environment).
The "spurious-clojure-example" project.clj file looks like...
(defproject spurious-clojure-example "0.1.0"
:description "This is an example application that utilises the Spurious Clojure AWS SDK Helper"
:url "https://github.com/integralist/spurious-clojure-example"
:dependencies [[org.clojure/clojure "1.6.0"]
[compojure "1.1.6"]
[hiccup "1.0.5"]
[ring-server "0.3.1"]
[amazonica "0.3.13"]
[environ "1.0.0"]]
:plugins [[lein-ring "0.8.12"]
[lein-environ "1.0.0"]]
:ring {:handler spurious-clojure-example.handler/app
:init spurious-clojure-example.handler/init
:destroy spurious-clojure-example.handler/destroy}
:profiles
{:uberjar {:aot :all}
:production
{:ring
{:open-browser? false, :stacktraces? false, :auto-reload? false}}
:dev
{:dependencies [[ring-mock "0.1.5"]
[ring/ring-devel "1.3.1"]
[spurious-aws-sdk-helper "0.1.0"]]}})
Notice I've put [spurious-aws-sdk-helper "0.1.0"] into :dev {:dependencies}.
The way the "spurious-clojure-aws-sdk-helper" code gets loaded is like so:
(if (env :debug) ; defined in profiles.clj
(do
(require '[spurious-aws-sdk-helper.core :as core])
(...other stuff...)))
The first thing I tried within my "spurious-aws-sdk-helper" project was...
lein pom
lein jar
lein install
...as I was told this would install "spurious-aws-sdk-helper" into the local directory ~/.m2 which Leiningen would look at first as a local cache of remote dependencies.
tree ~/.m2 | grep spurious
├── spurious-aws-sdk-helper
│ └── spurious-aws-sdk-helper
│ │ ├── spurious-aws-sdk-helper-0.1.0.jar
│ │ └── spurious-aws-sdk-helper-0.1.0.pom
│ │ ├── spurious-aws-sdk-helper-0.1.0-SNAPSHOT.jar
│ │ └── spurious-aws-sdk-helper-0.1.0-SNAPSHOT.pom
├── spurious-clojure-example
│ └── spurious-clojure-example
│ │ ├── spurious-clojure-example-0.1.0-SNAPSHOT.jar
│ │ └── spurious-clojure-example-0.1.0-SNAPSHOT.pom
This didn't work. When I connect my Vim editor to an nREPL and try to evaluate the require call to the library it would say it couldn't find the namespace.
I then tried doing the same lein pom/jar/install process for my "spurious-clojure-example" project (just in case there was some strange reason both projects needed to be locally installed). Again, no difference either, but i wasn't expected this to do anything really.
I then tried renaming my projects to remove the -SNAPSHOT from the version number (in case that made Leiningen think the dependency couldn't be used - nonsense I know, but I was clutching at straws).
I moved onto trying out the checkout feature (https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies) and when I evaluated the require call, that would pass through (e.g. no errors) but then one of the dependencies used by "spurious-aws-sdk-helper" would fail to load (i.e. org.clojure/data.json).
As a temporary measure I decided to add org.clojure/data.json to my "spurious-clojure-example" dependencies. So when evaluating the code again in the REPL, it this time got past the first two namespace errors but then it again errored because the spurious-aws-sdk-helper.s3 namespace couldn't be found :-/
At this point I realised I must be missing something really obvious, because it should not be this hard to test a library locally on your computer.
Could someone help me to resolve this problem.
Many thanks!
UPDATE: here is the result of lein classpath for "spurious-clojure-example"...
/Users/markmcdonnell/Code/spurious-clojure-example/test
/Users/markmcdonnell/Code/spurious-clojure-example/src
/Users/markmcdonnell/Code/spurious-clojure-example/dev-resources
/Users/markmcdonnell/Code/spurious-clojure-example/resources
/Users/markmcdonnell/Code/spurious-clojure-example/target/classes
/Users/markmcdonnell/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.macro/0.1.0/tools.macro-0.1.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-sqs/1.9.13/aws-java-sdk-sqs-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-s3/1.9.13/aws-java-sdk-s3-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-dynamodb/1.9.13/aws-java-sdk-dynamodb-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-swf-libraries/1.9.13/aws-java-sdk-swf-libraries-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/clojure/algo.generic/0.1.2/algo.generic-0.1.2.jar
/Users/markmcdonnell/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0.jar
/Users/markmcdonnell/.m2/repository/watchtower/watchtower/0.1.1/watchtower-0.1.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-config/1.9.13/aws-java-sdk-config-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-redshift/1.9.13/aws-java-sdk-redshift-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar
/Users/markmcdonnell/.m2/repository/clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-glacier/1.9.13/aws-java-sdk-glacier-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk/1.9.13/aws-java-sdk-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-directconnect/1.9.13/aws-java-sdk-directconnect-1.9.13.jar
/Users/markmcdonnell/.m2/repository/ring/ring-codec/1.0.0/ring-codec-1.0.0.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-server/7.6.8.v20121106/jetty-server-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/joda-time/joda-time/2.2/joda-time-2.2.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-ec2/1.9.13/aws-java-sdk-ec2-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-continuation/7.6.8.v20121106/jetty-continuation-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-lambda/1.9.13/aws-java-sdk-lambda-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-storagegateway/1.9.13/aws-java-sdk-storagegateway-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-ses/1.9.13/aws-java-sdk-ses-1.9.13.jar
/Users/markmcdonnell/.m2/repository/clj-stacktrace/clj-stacktrace/0.2.5/clj-stacktrace-0.2.5.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-opsworks/1.9.13/aws-java-sdk-opsworks-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-core/1.9.13/aws-java-sdk-core-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-util/7.6.8.v20121106/jetty-util-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/ring/ring-servlet/1.2.1/ring-servlet-1.2.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-simpleworkflow/1.9.13/aws-java-sdk-simpleworkflow-1.9.13.jar
/Users/markmcdonnell/.m2/repository/clj-time/clj-time/0.4.4/clj-time-0.4.4.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-logs/1.9.13/aws-java-sdk-logs-1.9.13.jar
/Users/markmcdonnell/.m2/repository/robert/hooke/1.3.0/hooke-1.3.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudsearch/1.9.13/aws-java-sdk-cloudsearch-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-simpledb/1.9.13/aws-java-sdk-simpledb-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudfront/1.9.13/aws-java-sdk-cloudfront-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-sts/1.9.13/aws-java-sdk-sts-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-codedeploy/1.9.13/aws-java-sdk-codedeploy-1.9.13.jar
/Users/markmcdonnell/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-kinesis/1.9.13/aws-java-sdk-kinesis-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-autoscaling/1.9.13/aws-java-sdk-autoscaling-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/amazon-kinesis-client/1.1.0/amazon-kinesis-client-1.1.0.jar
/Users/markmcdonnell/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar
/Users/markmcdonnell/.m2/repository/ring/ring-jetty-adapter/1.2.1/ring-jetty-adapter-1.2.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-support/1.9.13/aws-java-sdk-support-1.9.13.jar
/Users/markmcdonnell/.m2/repository/commons-fileupload/commons-fileupload/1.3/commons-fileupload-1.3.jar
/Users/markmcdonnell/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elasticbeanstalk/1.9.13/aws-java-sdk-elasticbeanstalk-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.reader/0.7.3/tools.reader-0.7.3.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cognitoidentity/1.9.13/aws-java-sdk-cognitoidentity-1.9.13.jar
/Users/markmcdonnell/.m2/repository/ring-refresh/ring-refresh/0.1.2/ring-refresh-0.1.2.jar
/Users/markmcdonnell/.m2/repository/org/tukaani/xz/1.5/xz-1.5.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudwatch/1.9.13/aws-java-sdk-cloudwatch-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-rds/1.9.13/aws-java-sdk-rds-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-importexport/1.9.13/aws-java-sdk-importexport-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudformation/1.9.13/aws-java-sdk-cloudformation-1.9.13.jar
/Users/markmcdonnell/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-route53/1.9.13/aws-java-sdk-route53-1.9.13.jar
/Users/markmcdonnell/.m2/repository/ring/ring/1.2.1/ring-1.2.1.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.namespace/0.1.3/tools.namespace-0.1.3.jar
/Users/markmcdonnell/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.2/jackson-databind-2.3.2.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elastictranscoder/1.9.13/aws-java-sdk-elastictranscoder-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elasticache/1.9.13/aws-java-sdk-elasticache-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/iq80/snappy/snappy/0.3/snappy-0.3.jar
/Users/markmcdonnell/.m2/repository/ring/ring-devel/1.2.1/ring-devel-1.2.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-kms/1.9.13/aws-java-sdk-kms-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-emr/1.9.13/aws-java-sdk-emr-1.9.13.jar
/Users/markmcdonnell/.m2/repository/clout/clout/1.1.0/clout-1.1.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudwatchmetrics/1.9.13/aws-java-sdk-cloudwatchmetrics-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.nrepl/0.2.6/tools.nrepl-0.2.6.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elasticloadbalancing/1.9.13/aws-java-sdk-elasticloadbalancing-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-iam/1.9.13/aws-java-sdk-iam-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-datapipeline/1.9.13/aws-java-sdk-datapipeline-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/2.5.0.v201103041518/javax.servlet-2.5.0.v201103041518.jar
/Users/markmcdonnell/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-sns/1.9.13/aws-java-sdk-sns-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudtrail/1.9.13/aws-java-sdk-cloudtrail-1.9.13.jar
/Users/markmcdonnell/.m2/repository/environ/environ/1.0.0/environ-1.0.0.jar
/Users/markmcdonnell/.m2/repository/net/jpountz/lz4/lz4/1.2.0/lz4-1.2.0.jar
/Users/markmcdonnell/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.3.2/jackson-core-2.3.2.jar
/Users/markmcdonnell/.m2/repository/compojure/compojure/1.1.6/compojure-1.1.6.jar
/Users/markmcdonnell/.m2/repository/ring-server/ring-server/0.3.1/ring-server-0.3.1.jar
/Users/markmcdonnell/.m2/repository/com/taoensso/nippy/2.7.0/nippy-2.7.0.jar
/Users/markmcdonnell/.m2/repository/amazonica/amazonica/0.3.13/amazonica-0.3.13.jar
/Users/markmcdonnell/.m2/repository/ring/ring-core/1.2.1/ring-core-1.2.1.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-io/7.6.8.v20121106/jetty-io-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-http/7.6.8.v20121106/jetty-http-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/org/clojure/core.incubator/0.1.0/core.incubator-0.1.0.jar
/Users/markmcdonnell/.m2/repository/com/taoensso/encore/1.11.2/encore-1.11.2.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cognitosync/1.9.13/aws-java-sdk-cognitosync-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.3.0/jackson-annotations-2.3.0.jar
UPDATE 2:
/Users/markmcdonnell/.m2
└── repository
├── amazonica
├── ant
├── antlr
├── aopalliance
├── args4j
├── asm
├── bbc
├── bidi
├── bouncycastle
├── ch
├── cheshire
├── circleci
├── classworlds
├── clj-stacktrace
├── clj-time
├── clojure-complete
├── clout
├── co
├── com
├── commons-beanutils
├── commons-cli
├── commons-codec
├── commons-collections
├── commons-digester
├── commons-discovery
├── commons-el
├── commons-fileupload
├── commons-httpclient
├── commons-io
├── commons-jelly
├── commons-jexl
├── commons-lang
├── commons-logging
├── commons-net
├── commons-validator
├── compojure
├── compojure-app
├── crypto-equality
├── crypto-random
├── de
├── dom4j
├── dotenv
├── doxia
├── environ
├── findbugs
├── geronimo-spec
├── hiccup
├── http-kit
├── instaparse
├── jackmorrill
├── javax
├── jaxen
├── jdom
├── jfree
├── jline
├── joda-time
├── junit
├── juxt
├── lein-dotenv
├── lein-environ
├── lein-ring
├── leinjacker
├── local
├── log4j
├── medley
├── modular
├── mx4j
├── nekohtml
├── net
├── ns-tracker
├── org
├── oro
├── pathetic
├── plexus
├── potemkin
├── prismatic
├── qdox
├── ring
├── ring-mock
├── ring-refresh
├── ring-server
├── robert
├── spurious-aws-sdk-helper
├── stax
├── thneed
├── tigris
├── trammel
├── velocity
├── watchtower
├── xalan
├── xerces
├── xml-apis
├── xom
└── xpp3
95 directories, 0 files
UPDATE 3: lein with-profile +dev classpath
/Users/markmcdonnell/Code/spurious-clojure-example/test
/Users/markmcdonnell/Code/spurious-clojure-example/src
/Users/markmcdonnell/Code/spurious-clojure-example/dev-resources
/Users/markmcdonnell/Code/spurious-clojure-example/resources
/Users/markmcdonnell/Code/spurious-clojure-example/target/classes
/Users/markmcdonnell/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.macro/0.1.0/tools.macro-0.1.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-sqs/1.9.13/aws-java-sdk-sqs-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-s3/1.9.13/aws-java-sdk-s3-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-dynamodb/1.9.13/aws-java-sdk-dynamodb-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-swf-libraries/1.9.13/aws-java-sdk-swf-libraries-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/clojure/algo.generic/0.1.2/algo.generic-0.1.2.jar
/Users/markmcdonnell/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0.jar
/Users/markmcdonnell/.m2/repository/watchtower/watchtower/0.1.1/watchtower-0.1.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-config/1.9.13/aws-java-sdk-config-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-redshift/1.9.13/aws-java-sdk-redshift-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar
/Users/markmcdonnell/.m2/repository/clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-glacier/1.9.13/aws-java-sdk-glacier-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk/1.9.13/aws-java-sdk-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-directconnect/1.9.13/aws-java-sdk-directconnect-1.9.13.jar
/Users/markmcdonnell/.m2/repository/ring/ring-codec/1.0.0/ring-codec-1.0.0.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-server/7.6.8.v20121106/jetty-server-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/joda-time/joda-time/2.2/joda-time-2.2.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-ec2/1.9.13/aws-java-sdk-ec2-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-continuation/7.6.8.v20121106/jetty-continuation-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-lambda/1.9.13/aws-java-sdk-lambda-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-storagegateway/1.9.13/aws-java-sdk-storagegateway-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-ses/1.9.13/aws-java-sdk-ses-1.9.13.jar
/Users/markmcdonnell/.m2/repository/clj-stacktrace/clj-stacktrace/0.2.5/clj-stacktrace-0.2.5.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-opsworks/1.9.13/aws-java-sdk-opsworks-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-core/1.9.13/aws-java-sdk-core-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-util/7.6.8.v20121106/jetty-util-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/ring/ring-servlet/1.2.1/ring-servlet-1.2.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-simpleworkflow/1.9.13/aws-java-sdk-simpleworkflow-1.9.13.jar
/Users/markmcdonnell/.m2/repository/clj-time/clj-time/0.4.4/clj-time-0.4.4.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-logs/1.9.13/aws-java-sdk-logs-1.9.13.jar
/Users/markmcdonnell/.m2/repository/robert/hooke/1.3.0/hooke-1.3.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudsearch/1.9.13/aws-java-sdk-cloudsearch-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-simpledb/1.9.13/aws-java-sdk-simpledb-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudfront/1.9.13/aws-java-sdk-cloudfront-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-sts/1.9.13/aws-java-sdk-sts-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-codedeploy/1.9.13/aws-java-sdk-codedeploy-1.9.13.jar
/Users/markmcdonnell/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-kinesis/1.9.13/aws-java-sdk-kinesis-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-autoscaling/1.9.13/aws-java-sdk-autoscaling-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/amazon-kinesis-client/1.1.0/amazon-kinesis-client-1.1.0.jar
/Users/markmcdonnell/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar
/Users/markmcdonnell/.m2/repository/ring/ring-jetty-adapter/1.2.1/ring-jetty-adapter-1.2.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-support/1.9.13/aws-java-sdk-support-1.9.13.jar
/Users/markmcdonnell/.m2/repository/commons-fileupload/commons-fileupload/1.3/commons-fileupload-1.3.jar
/Users/markmcdonnell/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elasticbeanstalk/1.9.13/aws-java-sdk-elasticbeanstalk-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.reader/0.7.3/tools.reader-0.7.3.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cognitoidentity/1.9.13/aws-java-sdk-cognitoidentity-1.9.13.jar
/Users/markmcdonnell/.m2/repository/ring-refresh/ring-refresh/0.1.2/ring-refresh-0.1.2.jar
/Users/markmcdonnell/.m2/repository/org/tukaani/xz/1.5/xz-1.5.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudwatch/1.9.13/aws-java-sdk-cloudwatch-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-rds/1.9.13/aws-java-sdk-rds-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-importexport/1.9.13/aws-java-sdk-importexport-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudformation/1.9.13/aws-java-sdk-cloudformation-1.9.13.jar
/Users/markmcdonnell/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-route53/1.9.13/aws-java-sdk-route53-1.9.13.jar
/Users/markmcdonnell/.m2/repository/ring/ring/1.2.1/ring-1.2.1.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.namespace/0.1.3/tools.namespace-0.1.3.jar
/Users/markmcdonnell/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.2/jackson-databind-2.3.2.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elastictranscoder/1.9.13/aws-java-sdk-elastictranscoder-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elasticache/1.9.13/aws-java-sdk-elasticache-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/iq80/snappy/snappy/0.3/snappy-0.3.jar
/Users/markmcdonnell/.m2/repository/ring/ring-devel/1.2.1/ring-devel-1.2.1.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-kms/1.9.13/aws-java-sdk-kms-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-emr/1.9.13/aws-java-sdk-emr-1.9.13.jar
/Users/markmcdonnell/.m2/repository/clout/clout/1.1.0/clout-1.1.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudwatchmetrics/1.9.13/aws-java-sdk-cloudwatchmetrics-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/clojure/tools.nrepl/0.2.6/tools.nrepl-0.2.6.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-elasticloadbalancing/1.9.13/aws-java-sdk-elasticloadbalancing-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-iam/1.9.13/aws-java-sdk-iam-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-datapipeline/1.9.13/aws-java-sdk-datapipeline-1.9.13.jar
/Users/markmcdonnell/.m2/repository/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/2.5.0.v201103041518/javax.servlet-2.5.0.v201103041518.jar
/Users/markmcdonnell/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-sns/1.9.13/aws-java-sdk-sns-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cloudtrail/1.9.13/aws-java-sdk-cloudtrail-1.9.13.jar
/Users/markmcdonnell/.m2/repository/environ/environ/1.0.0/environ-1.0.0.jar
/Users/markmcdonnell/.m2/repository/net/jpountz/lz4/lz4/1.2.0/lz4-1.2.0.jar
/Users/markmcdonnell/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.3.2/jackson-core-2.3.2.jar
/Users/markmcdonnell/.m2/repository/compojure/compojure/1.1.6/compojure-1.1.6.jar
/Users/markmcdonnell/.m2/repository/ring-server/ring-server/0.3.1/ring-server-0.3.1.jar
/Users/markmcdonnell/.m2/repository/com/taoensso/nippy/2.7.0/nippy-2.7.0.jar
/Users/markmcdonnell/.m2/repository/amazonica/amazonica/0.3.13/amazonica-0.3.13.jar
/Users/markmcdonnell/.m2/repository/ring/ring-core/1.2.1/ring-core-1.2.1.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-io/7.6.8.v20121106/jetty-io-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/org/eclipse/jetty/jetty-http/7.6.8.v20121106/jetty-http-7.6.8.v20121106.jar
/Users/markmcdonnell/.m2/repository/org/clojure/core.incubator/0.1.0/core.incubator-0.1.0.jar
/Users/markmcdonnell/.m2/repository/com/taoensso/encore/1.11.2/encore-1.11.2.jar
/Users/markmcdonnell/.m2/repository/com/amazonaws/aws-java-sdk-cognitosync/1.9.13/aws-java-sdk-cognitosync-1.9.13.jar
/Users/markmcdonnell/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.3.0/jackson-annotations-2.3.0.jar
Justin Smith from the #clojure irc channel helped me to resolve this issue.
It seems that just running lein install was enough, but the real issue was that the error I was seeing about the namespace not being found was actually misleading as there were errors within my helper library that needed to be fixed first before I could load it successfully in my example application.
The advice was to test thoroughly within the REPL (e.g. attempt to load the helper namespace within the helper's own REPL and if it doesn't work then run a linter to verify there is no issues with the code itself).
lein install is the correct approach, but you must have some inconsistency in naming or versions.
It can be helpful to show the classpath that leiningen is actually using:
lein classpath
Or with a profile (the +dev means default +dev):
lein with-profile +dev classpath
You should find the library somewhere under ~/.m2 listed in the output.
lein deps :tree is similar and you may find it easier to find the inconsistency via that.
I had essentially the same issue, could not deal with it for 1.5 days...
The solution involved:
Getting the groupid/artifactid dependancies right in all project.clj files and in the namespace declarations.
There was an unused test file in the library project that had a reference to another charting library which was not declared in the project.clj file. The project compiled and installed without this charting lib declaration. However, referencing this lib using the local repo did not work until I removed this test file (or included the needed charting lib dependency in its project.clj)
I had to remove both of these manual local repository declarations from project.clj files:
:local-repo "file:/home/atmamta/.m2/repository/"
:repositories [["local" "file:/home/atmamta/.m2/repository/"]]
Uninstalled cider snapshot version and its dependent emacs libraries, reinstalled them using the latest stable versions, and modified my ~/.lein/profiles.clj to reflect these changes.
I.e. I changed the [cider/cider-nrepl "SNAPSHOT-x.y.z"] line to [cider/cider-nrepl "0.8.2"] in {:user {:plugins ...}} in file ~/.lein/profiles.clj
Important: cider version has to be the same as cider-nrepl version.
I've been striving to build a standalone .jar with leiningen. Though having gone through the examples on github and Alex Ott's Website and some related questions, I couldn't figure out how to correctly set up the project. After doing lein uberjar in the project it complains
Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath: (collision.clj:1)
My project directory looks like
.
├── classes
├── lib
│ ├── clojure-1.2.1.jar
│ └── clojure-contrib-1.1.0.jar
├── project.clj
└── src
└── collision
└── collision.clj
My project.clj:
(defproject collision "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.1.0"]]
:main collision.collision)
collision.clj:
(ns collision.collision
(:require
clojure.set
clojure.string
[clojure.contrib.string :as st]
[clojure.contrib.str-utils :as su]
[clojure.contrib.combinatorics :as cmbn]))
... defns ...
(defn -main []
(...))
(-main)
The code works on the REPL. How do I tell leiningen where to to find clojure-contrib-1.1.0.jar? I'm not a Java programmer and not really accustomed to the classpath issue; quick and dirty help is much appreciated.
try using [org.clojure/clojure-contrib "1.2.0"] instead [org.clojure/clojure-contrib "1.1.0"]
in the version 1.1.0 not exist the namespace clojure.contrib.string