clojure - Can't build a jar using Leiningen -
i'm trying make stand alone jar bare-bones clojure project using leiningen plugin in intellij's cursive.
to create project, created project.clj file, opened it, , cursive offered import project.
project.clj:
(defproject watertimer "1" :description "a timer reminds drink water" :main tone-producer/main)
tone-producer.clj:
(ns tone-producer (:require [general-helpers :as g]) (:import [javax.sound.midi midisystem synthesizer midichannel]) (:gen-class)) (defn main [& args] (println "test!"))
when run "uberjar" task, following output:
warning: specified :main without including in :aot. implicit aot of :main removed in leiningen 3.0.0. if need aot uberjar, consider adding :aot :all :uberjar profile instead. warning: main-class specified not exist within jar. may not executable expected. gen-class directive may missing in namespace contains main method. created c:\users\slomi\ideaprojects\watertimer\target\watertimer-1.jar created c:\users\slomi\ideaprojects\watertimer\target\watertimer-1-standalone.jar
i tried changing main
function have default name, , omit name defproject
:
(defproject watertimer "1" :description "a timer reminds drink water" :main tone-producer) (ns tone-producer (:require [general-helpers :as g]) (:import [javax.sound.midi midisystem synthesizer midichannel]) (:gen-class)) (defn -main [& args] (println "test!"))
but error:
error: not find or load main class clojure.main compilation failed: subprocess failed
the structure is:
- watertimer
- src
- tone-producer.clj
- project.clj
- target
- src
any guidance here appreciated.
after bit of fiddling
- i dropped
(:require [general-helpers :as g])
since not necessary demostrate issue - error: not find or load main class clojure.main compilation failed
- you didn't include clojure dependency [1]
:gen-class
needs aot - sanchayan pointed out- see [2]
project.clj
(defproject watertimer "0.0.1" :description "a timer reminds drink water" :dependencies [[org.clojure/clojure "1.8.0"]] ;; <- [1] :main tone-producer :aot [tone-producer]) ;; <- [2]
src/tone_producer.clj - use '_' instead of '-' in filename
(ns tone-producer (:import [javax.sound.midi midisystem synthesizer midichannel]) (:gen-class)) (defn -main [& args] (println "test!"))
result:
$ lein uberjar compiling tone-producer compiling tone-producer created .../watertimer/target/watertimer-0.0.1.jar created .../watertimer/target/watertimer-0.0.1-standalone.jar $ java -jar target/watertimer-0.0.1-standalone.jar test!
generally i'd recommend init project lein new <name>
via command line , import cursive/other ide of choice.
Comments
Post a Comment