I am currently newbie in Leiningen project. I want to compile less to css using lein-less and minify-assets on the fly so I found that I should use lein less auto for the less file and lein minify-assets watch for javascripts and HTML file.
I am using lein-cascade to operate them but it just still on the lein less auto task and not go to lein minify-assets watch
This is my project code
(defproject indecorlein "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"]]
:plugins [[lein-asset-minifier "0.4.3"]
[lein-less "1.7.5"]
[lein-cascade "0.1.2"]]
:min-lein-version "2.5.0"
:cascade {
"lessc" [["less" "auto"]]
"min" [["minify-assets" "watch"]]
"amp" ["lessc" "min"]
}
:less {:source-paths ["dev/resources/less"]
:target-path "dev/resources/css"}
:minify-assets [
[:html {:source "dev/resources/html" :target "dev/minified/html"}]
[:css {:source "dev/resources/css" :target "dev/minified/css/styles.min.css"}]
[:js {:source ["dev/res/js"] :target "dev/minified/js/amp.min.js"}]])
Maybe there's a solution about this or me just run the tasks on separate terminal tabs.
You can use lein-pdo plugin. Add it into your plugins and define an alias:
:plugins [...
[lein-pdo "0.1.1"]]
:aliases {"watch" ["pdo" ["less" "auto"]
["minify-assets" "watch"]]}
Then you can run lein watch which will run both tasks at the same time.
The problem is that both lein less auto and lein minify-assets watch do not return. I've used lein less auto in the past in a console on its own.
Related
I am trying to run datomic's in-memory database with this tutorial https://clojureverse.org/t/a-quick-way-to-start-experimenting-with-datomic/5004 with the free version. I downloaded the .zip file and put it in program files. Then I created a project with leiningen and I did the other steps indicated in the tutorial, but when I want to evaluate the lines with the repl for creating the database and connection it throws:
"Error:
Syntax error compiling at (c:\Users\usuario\Desktop\clojure\datomic-shortcut\src\datomic_shortcut\core.clj:7:3).
No such namespace: d"
... and when I evaluate the entire file, the following:
Evaluating file: core.clj
Syntax error (FileNotFoundException) compiling at (c:\Users\usuario\Desktop\clojure\datomic-shortcut\src\datomic_shortcut\core.clj:1:1).
Could not locate datomic/api__init.class, datomic/api.clj or datomic/api.cljc on classpath.
Evaluation of file core.clj failed: class clojure.lang.Compiler$CompilerException
When checking the .m2 folder there is no datomic's dependency, even after trying 'lein deps'
I think it can be solved with lein pom/jar/install sequence but I dont find where or I dont know how to download the .jar file.
Any help or information is welcome.. thanks!
-------------EDIT--------------------
Im sorry, the .m2 folder contains the ...m2\repository\com\datomic\datomic-free\0.9.5697\datomic-free-0.9.5697.jar file indeed.
No errors with 'lein deps'
My project.clj:
(defproject datomic-shortcut "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[com.datomic/datomic-free "0.9.5697"]]
:source-paths ["src"]
:repl-options {:init-ns datomic-shortcut.core})
My core.clj:
(ns datomic-shortcut.core
(:require [datomic.api :as d]))
(def db-uri "datomic:mem://foo")
(comment
(d/create-database db-uri)
(def conn (d/connect db-uri)))
I realized the classpath hasn't the .jar file in it.
C:\Users\usuario\Desktop\clojure\datomic-shortcut>lein classpath
=>
C:\Users\usuario\Desktop\clojure\datomic-shortcut\test;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\src;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\dev-resources;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\resources;
C:\Users\usuario\Desktop\clojure\datomic-shortcut\target\classes;
C:\Users\usuario\.m2\repository\com\datomic\datomic-lucene-core\3.3.0\datomic-lucene-core-3.3.0.jar;
C:\Users\usuario\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;
C:\Users\usuario\.m2\repository\com\h2database\h2\1.3.171\h2-1.3.171.jar;
C:\Users\usuario\.m2\repository\org\apache\activemq\artemis-commons\1.4.0\artemis-commons-1.4.0.jar;
C:\Users\usuario\.m2\repository\nrepl\nrepl\0.6.0\nrepl-0.6.0.jar;
C:\Users\usuario\.m2\repository\org\apache\tomcat\tomcat-juli\7.0.27\tomcat-juli-7.0.27.jar;
C:\Users\usuario\.m2\repository\clojure-complete\clojure-complete\0.2.5\clojure-complete-0.2.5.jar;
C:\Users\usuario\.m2\repository\org\slf4j\jul-to-slf4j\1.7.7\jul-to-slf4j-1.7.7.jar;
C:\Users\usuario\.m2\repository\leinjacker\leinjacker\0.4.1\leinjacker-0.4.1.jar;
C:\Users\usuario\.m2\repository\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;
C:\Users\usuario\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.7\jcl-over-slf4j-1.7.7.jar;
C:\Users\usuario\.m2\repository\org\clojure\core.contracts\0.0.1\core.contracts-0.0.1.jar;
C:\Users\usuario\.m2\repository\org\codehaus\janino\commons-compiler\2.6.1\commons-compiler-2.6.1.jar;
C:\Users\usuario\.m2\repository\com\datomic\datomic-free\0.9.5697\datomic-free-0.9.5697.jar;
C:\Users\usuario\.m2\repository\org\clojure\core.unify\0.5.3\core.unify-0.5.3.jar;
C:\Users\usuario\.m2\repository\org\apache\johnzon\johnzon-core\0.9.4\johnzon-core-0.9.4.jar;
C:\Users\usuario\.m2\repository\commons-beanutils\commons-beanutils\1.9.2\commons-beanutils-1.9.2.jar;
C:\Users\usuario\.m2\repository\org\slf4j\log4j-over-slf4j\1.7.7\log4j-over-slf4j-1.7.7.jar;
C:\Users\usuario\.m2\repository\useful\useful\0.8.5-alpha2\useful-0.8.5-alpha2.jar;
C:\Users\usuario\.m2\repository\org\slf4j\slf4j-nop\1.7.7\slf4j-nop-1.7.7.jar;
C:\Users\usuario\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;
C:\Users\usuario\.m2\repository\org\clojure\tools.cli\0.3.5\tools.cli-0.3.5.jar;
C:\Users\usuario\.m2\repository\lein-datomic\lein-datomic\0.2.0\lein-datomic-0.2.0.jar;
C:\Users\usuario\.m2\repository\org\fressian\fressian\0.6.5\fressian-0.6.5.jar;
C:\Users\usuario\.m2\repository\org\apache\geronimo\specs\geronimo-json_1.0_spec\1.0-alpha-1\geronimo-json_1.0_spec-1.0-alpha-1.jar;
C:\Users\usuario\.m2\repository\me\raynes\conch\0.4.0\conch-0.4.0.jar;
C:\Users\usuario\.m2\repository\org\apache\activemq\artemis-core-client\1.4.0\artemis-core-client-1.4.0.jar;
C:\Users\usuario\.m2\repository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;
C:\Users\usuario\.m2\repository\org\clojure\clojure\1.10.1\clojure-1.10.1.jar;
C:\Users\usuario\.m2\repository\io\netty\netty-all\4.0.39.Final\netty-all-4.0.39.Final.jar;
C:\Users\usuario\.m2\repository\org\clojure\core.specs.alpha\0.2.44\core.specs.alpha-0.2.44.jar;
C:\Users\usuario\.m2\repository\org\codehaus\janino\commons-compiler-jdk\2.6.1\commons-compiler-jdk-2.6.1.jar;
C:\Users\usuario\.m2\repository\org\clojure\tools.macro\0.1.1\tools.macro-0.1.1.jar;
C:\Users\usuario\.m2\repository\org\apache\tomcat\tomcat-jdbc\7.0.27\tomcat-jdbc-7.0.27.jar;
C:\Users\usuario\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;
C:\Users\usuario\.m2\repository\org\clojure\spec.alpha\0.2.176\spec.alpha-0.2.176.jar
So then I tried:
C:\Users\usuario\Desktop\clojure\datomic-shortcut>java -cp C:/Users/usuario/.m2/repository/com/datomic/datomic-free/0.9.5697/datomic-free-0.9.5697.jar clojure.main
Error: no se ha encontrado o cargado la clase principal clojure.main
I was trying out on a project generated by lein new. But I couldn't get lein repl working and the output was not very helpful in terms of trouble-shooting. Here's the stack trace:
Exception in thread "main" java.lang.AssertionError: Assert failed: transport-fn, compiling:(/private/var/folders/02/rhhhdqmd3sn969wx0v68v3440b2221/T/form-init8538067533760352114.clj:1:125)
at clojure.lang.Compiler.load(Compiler.java:7526)
at clojure.lang.Compiler.loadFile(Compiler.java:7452)
at clojure.main$load_script.invokeStatic(main.clj:278)
at clojure.main$init_opt.invokeStatic(main.clj:280)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invokeStatic(main.clj:311)
at clojure.main$null_opt.invokeStatic(main.clj:345)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
Caused by: java.lang.AssertionError: Assert failed: transport-fn
at nrepl.core$connect.invokeStatic(core.clj:168)
at nrepl.core$connect.doInvoke(core.clj:168)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at nrepl.ack$send_ack.invokeStatic(ack.clj:45)
at nrepl.ack$send_ack.invoke(ack.clj:41)
at nrepl.server$start_server.invokeStatic(server.clj:146)
at nrepl.server$start_server.doInvoke(server.clj:105)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at logical.core$eval1421.invokeStatic(form-init8538067533760352114.clj:1)
at logical.core$eval1421.invoke(form-init8538067533760352114.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:7062)
at clojure.lang.Compiler.eval(Compiler.java:7052)
at clojure.lang.Compiler.eval(Compiler.java:7052)
at clojure.lang.Compiler.load(Compiler.java:7514)
... 12 more
Here's the version of leiningen from lein version:
Leiningen 2.8.2 on Java 11.0.1 OpenJDK 64-Bit Server VM
And here's the project.clj:
(defproject logical "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.9.0"]]
:main logical.core
:repl-options {:init-ns logical.core})
There's also nothing in ~/.lein but content generated by leiningen itself. This is run on a MacOS Mojave version 10.14.2.
This is a known issue with the latest 2.8.2 release of leiningen
Easiest solution is probably to downgrade to 2.8.1 until the next release.
What can cause lein uberjar to fail with "Caused by: java.lang.ClassNotFoundException" errors when lein run runs my app successfully? I'm using leiningen 2.5.1.
It looks like leiningen provides profiles as a way to make custom environments for certain tasks. However, I don't believe a profile difference between what is happening with lein run and lein uberjar is responsible because ...
1) I tried producing the uberjar with every possible profile, via lein with-profile <profile> for every <profile> named in the output of lein show-profiles.
2) I ran lein with-profile uberjar run, and no errors arose.
In case the answer to this problem and similar problems might be specific to the classes and dependencies involved, it is classes related to Overtone that produce the ClassNoteFoundException errors.
My project.clj file looks like:
(defproject cochlea "0.1.0-SNAPSHOT"
:description "An interactive ear training GUI application"
:url "http://github.com/seewalker/cochlea"
:license {:name "GPL v3"
:url "http://www.gnu.org/copyleft/gpl.html"}
:repositories {"conjars" "http://conjars.org/repo"}
:dependencies [[org.clojure/clojure "1.5.1"]
[overtone "0.9.1"]
[org.clojure/tools.trace "0.7.5"]
[org.clojure/java.jdbc "0.3.7"]
[postgresql "9.1-901.jdbc4"]
[environ "0.5.0"]
[incanter "1.9.0"]
[clj-time "0.9.0"]
[me.raynes/conch "0.8.0"]
[seesaw "1.4.2" :exclusions [org.clojure/clojure]]]
:profiles { :uberjar {:aot :all} }
:repl-options { :timeout 120000}
:main cochlea.core
:target-path "target/%s")
once i added one more namespace in my (toy) project one exception is raised after starting the server:
lein run
I am copying below my project.clj file.
(defproject compoj02 "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.6.0"]
[ring "1.3.1"]
[compojure "1.2.1"]
[clout "2.0.0"]
[enlive "1.1.5"]
[org.clojure/data.csv "0.1.2"]
;[org.clojure/data.csv]
]
:main compoj02.core)
The error is
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/data/csv__init.class or clojure/data/csv.clj on classpath: , compiling:(compoj02/pompaq.clj:1:1)
at clojure.lang.Compiler.load(Compiler.java:7142)
The new namespace contains one simple function:
(ns compoj02.pompaq
(:require [clojure.data.csv :as csv]
[clojure.data.io :as iov]))
(defn process-csv [file]
(with-open [in-file (iov/reader file)]
(doall
(csv/read-csv in-file))))
thanks for reading!
PS. I am adding few details.I executed the command lein deps. Also, there is a chain of files: core.clj uses a reference to templates.clj and this one uses a reference to the pompaq.clj. When I comment out the declaration (:use compoj02.pompaq) used in the namespace of templates.clj, I am able to start the application via lein run.
Try lein deps to make sure everything is there. Also, without a -main function, your command should be =>
lein run -m compoj02.pompaq/process-csv file-arg-here
I've created a simple example using:
%> lein new lein-check
I've only modified the code so that it now has a 'main':
(defproject lein-check "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 "lein-check.core"
:dependencies [[org.clojure/clojure "1.4.0"]])
(ns lein-check.core
(:gen-class))
(defn -main
"I don't do a whole lot."
[& args]
(println "Hello, World!"))
But the first time I run lein uberjar even after a clean I get this:
Compiling lein-check.core
Exception in thread "main" java.lang.ClassCastException:
java.lang.String cannot be cast to clojure.lang.Symbol
at clojure.core$find_ns.invoke(core.clj:3659)
at clojure.core$load_one.invoke(core.clj:5228)
at clojure.core$compile$fn__4895.invoke(core.clj:5426)
at clojure.core$compile.invoke(core.clj:5425)
at user$eval7.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6511)
at clojure.lang.Compiler.eval(Compiler.java:6501)
at clojure.lang.Compiler.eval(Compiler.java:6477)
at clojure.core$eval.invoke(core.clj:2797)
at clojure.main$eval_opt.invoke(main.clj:297)
at clojure.main$initialize.invoke(main.clj:316)
at clojure.main$null_opt.invoke(main.clj:349)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Compilation failed: Subprocess failed
Running a follow up uberjar though successfully creates the jars:
Created ....\lein-check-0.1.0-SNAPSHOT.jar
Including lein-check-0.1.0-SNAPSHOT.jar
Including clojure-1.4.0.jar
Created ....\lein-check-0.1.0-SNAPSHOT-standalone.jar
Is uberjar sometimes running the main after a completion? Is it supposed to do that? I'm not quite sure if this is a user error, a lein bug or a clojure bug.
The problem is in the line
:main "lein-check.core"
It should be
:main lein-check.core
You're using a string instead of a symbol.
Well it turns out that the Lein Sample Project show the :main as a symbol and not a string. Once this was updated then running lein uberjar works as expected.
This line in particular:
:main "lein-check.core"
changed to:
:main 'lein-check.core