On Sat, Oct 23, 2010 at 8:53 AM, Ralph wrote:
> Won't work. The "def" gets executed at compile time, before the JAR
> file exists.
>
I'm very confused by what you mean by this. If I do the following, I
get a new random value every time I run it, which does not seem to
match what you are saying:
That's interesting... Hadn't thought of using delay. A user on
Stackoverflow (kotarak) suggested using alter-var-root. This method
will also support setting values for command line arguments.
On Oct 24, 3:33 pm, Stuart Sierra wrote:
> Here's one way:
>
> (def version (delay (... read the JAR
Here's one way:
(def version (delay (... read the JAR ...))
(defn get-version [] (force version))
-S
On Oct 22, 11:56 am, Ralph wrote:
> I have a Clojure program that I build as a JAR file using Maven.
> Embedded in the JAR Manifest is a build-version number, including the
> build tim
This is literally the way we "think"...but if we all verbalized it this
way... we would all have a stack overflow at runtime.
On Fri, Oct 22, 2010 at 11:56 AM, Ralph wrote:
> I have a Clojure program that I build as a JAR file using Maven.
> Embedded in the JAR Manifest is a build-version numb
- Why not make the jar available at compile time as well? (e.g. maven
scope="provided")
- You could also use a delay:
(def *version* (delay (get-version)))
and then write @*version* when you want the version information at runtime.
- Equivalently, you could memoize get-version and just call tha
Won't work. The "def" gets executed at compile time, before the JAR
file exists.
On Oct 22, 3:55 pm, ataggart wrote:
> (defn get-version []
> (-> (str "jar:" (-> my.ns.name (.getProtectionDomain)
> (.getCodeSource)
> (.getLocatio
(defn get-version []
(-> (str "jar:" (-> my.ns.name (.getProtectionDomain)
(.getCodeSource)
(.getLocation))
"!/META-INF/MANIFEST.MF")
(URL.)
(.openStream)
(Manifest.)
(.. getMainAttributes)
(.g
Yes. I does not work. The "def" gets evaluated at compile-time, not
run-time. The JAR file that the code is reading does not exist until
after the program is compiled.
On Oct 22, 12:28 pm, James Reeves wrote:
> Is there a reason why you can't (def version ...) directly, without
> calling it via a
Is there a reason why you can't (def version ...) directly, without
calling it via a set-version function?
- James
On 22 October 2010 16:56, Ralph wrote:
> I have a Clojure program that I build as a JAR file using Maven.
> Embedded in the JAR Manifest is a build-version number, including the
> b