I have the following code in a cljc file:
(ns proj
#?(:cljs
(:require-macros
[proj :refer [define-project-version]])))
(declare project-version)
#?(:clj
(defmacro define-project-version []
`(def ~'project-version ~(first (drop 2 (read-string (slurp "project.clj")))))))
(define-project-version)
This does work when used in clj files and when starting the REPL. However as soon as I make an uberjar and try to run it I get an exception regarding project.clj - "No such file or directory." The error comes from the ClojureScript part. The uberjar is compiled just fine.
Why is it that the code tries to load project.clj? Aren't macros supposed to be run at compile time?
define-project-version
only for Clojure platform (not for ClojureScript). Is this supposed to be so? – Lea