Fork me on GitHub
#boot
<
2015-09-14
>
boz04:09:23

Hi, I’m having trouble getting -main to work in a jar. I’m making a little survival command line game, so the -main is in survival/cli.clj like so …

(ns survival.cli
 (:require [survival.play :as play]))

(defn -main [& args]
  (println "Hi”))
my build.boot is …
(set-env!
:source-paths #{"src" "test"}
 :dependencies '[[midje "1.7.0" :scope "test”]
[zilti/boot-midje "0.1.2" :scope "test"]])

(require '[zilti.boot-midje :refer [midje]])

(task-options!
 aot {:all true}
 pom {:project ‘survival
:version "0.1.0"}
 jar {:main 'survival.cli})

(deftask build []
  (comp (aot) (pom) (uber) (jar)))
running boot build makes the jar with the cli compiled in it
$ jar -tf target/survival-0.1.0.jar | grep cli
survival/cli$_main.class
survival/cli__init.class
survival/cli$loading__5340__auto____244.class
survival/cli$fn__310.class
but the jar doesn’t work …
$ java -jar target/survival-0.1.0.jar
Error: Could not find or load main class survival.cli
I’m stumped 😕 what did I miss? (using boot version 2.2.0 and clojure 1.7.0)

juhoteperi05:09:46

@boz: Looks like aot {:all true} is not working. You can either try to find out reason for that or move clj sources to resource-paths so that they are available in the jar

joelkuiper11:09:33

@juhoteperi: Hey, I’m trying to get boot-less to work with less4j-javascript, but I keep getting java.lang.IllegalArgumentException: No matching field found: getSourceMapConfiguration for class com.github.sommeri.less4j.LessCompiler$Configuration

joelkuiper11:09:44

Is this something I can fix on my side?

juhoteperi11:09:02

@joelkuiper: What is less4j-javascript?

joelkuiper11:09:23

an extension to less that allows you to evaluate inline javascript

joelkuiper11:09:17

I have a bunch of mixins from another project that look like

.boxShadow(@value1,@value2:X,...) {
    @value: ~`"@{arguments}".replace(/[\[\]]|\,\sX/g, '')`;

    -moz-box-shadow: @value;
    -webkit-box-shadow: @value;
    box-shadow: @value;
}

joelkuiper11:09:08

which throws an error with just vanilla less4j (not the “standard” command line tools though)

joelkuiper11:09:59

eg ERROR file:...mixins.less 95:13 Escaped script ~`...`are not supported. The problem can be solved using custom functions. Compilation resulted in incorrect CSS.

juhoteperi12:09:06

@joelkuiper: What are you doing currently? Looks like Less4Javascript requires custom configuration object

joelkuiper12:09:53

currently I’m forking less4clj and trying if I can jerryrig the library in 😛

juhoteperi12:09:53

Yeah, that should work

joelkuiper12:09:50

you’re aware that your tests fail?

alandipert12:09:40

the less4j-javascript concept is mindbending

xifi12:09:19

in a good or bad way

alandipert12:09:22

not sure yet, still bending

joelkuiper12:09:44

@juhoteperi: shall and try and update boot-less as well?

joelkuiper12:09:29

I’m not completely convinced either of its merits. But I need to share style sheets with another project where the devs love it … so enabling support is easier than refactoring 😛

joelkuiper12:09:47

and apparently it’s build in functionality of the nodejs less compiler

boz15:09:03

@juhoteperi: Thanks for the reply simple_smile It wasn’t the AOT, it was a missing (:gen-class) and then I discovered I’d forgot the clojure dependency in build.boot Works with cli.clj...

(ns survival.cli
  (:require [survival.play :as play])
  (:gen-class))

(defn -main [& args]
  (println "Hi”))
and build.boot
(set-env!
 :source-paths #{"src" "test"}
 :dependencies '[[org.clojure/clojure "1.7.0"]
                 [midje "1.7.0" :scope "test"]
                 [zilti/boot-midje "0.1.2" :scope "test"]])

(require '[zilti.boot-midje :refer [midje]])

(task-options!
 aot {:all true}
 pom {:project 'survival
      :version "0.1.0"}
 jar {:main 'survival.cli})

(deftask build
  "Builds a runnable jar for the CLI Survival game."
  []
  (comp (aot) (pom) (uber) (jar)))

sparkofreason20:09:19

Anybody see this exception when including deps.cljs? clojure.lang.ExceptionInfo: No ns form found in file:/home/dave/.boot/cache/tmp/home/dave/allgress/survey-response/jl6/-c4hx1l/deps.cljs at line 1 /home/dave/.boot/cache/tmp/home/dave/allgress/survey-response/jl6/aebh7k/boot/cljs/main2339.cljs

sparkofreason21:09:38

Never mind - adding the .cljs.edn file fixed it.

micha21:09:08

oh interesting, i think we should probably fix something in boot-cljs

micha21:09:23

i noticed the analyzer has a list of "reserved" file names

micha21:09:29

"deps.cljs" being one

micha21:09:44

since it has the .cljs extension but it's not a cljs namespace

micha21:09:02

this is why we use .cljs.edn btw, and not .cljs

micha21:09:24

so we need to special case it and make sure cljs doesn't try to compile it