librelist archives

« back to archive

How to enforce java (runtime/library) version dependency?

How to enforce java (runtime/library) version dependency?

From:
Dave Tenny
Date:
2013-12-03 @ 20:49
How can I express that I want my clojure project to run with java 1.7
jre/libraries?   It doesn't need to be compiled with 1.7, but I want to
ensure that the NIO2 libraries of Java7 are present if someone attempts to
import the module and/or build the project with leiningen.

Re: [leiningen] How to enforce java (runtime/library) version dependency?

From:
John Gabriele
Date:
2013-12-05 @ 03:46
On Tue, Dec 3, 2013, at 12:49 PM, Dave Tenny wrote:
> How can I express that I want my clojure project to run with java 1.7
> jre/libraries?   It doesn't need to be compiled with 1.7, but I want to
> ensure that the NIO2 libraries of Java7 are present if someone attempts
> to
> import the module and/or build the project with leiningen.

Looks like you can set :java-cmd in your project.clj's defproject:

    :java-cmd "/home/phil/bin/funky-java"

If you want `lein` itself to start up using funky-java, I think you can
set the JAVA_CMD env var, but I haven't tested it:

    JAVA_CMD=funky-java lein version

-- 
  John Gabriele
  jgabriele@fastmail.fm

Re: [leiningen] How to enforce java (runtime/library) version dependency?

From:
Dave Tenny
Date:
2013-12-05 @ 13:13
Yeah I was hoping for something more like a dependency like
[com.oracle.java/jre "1.7.0"] or something like that.  However I can't
imagine something like that working since there are no jre artifacts.  I
just wondered if there was some semantic equivalent.

Specifying a java command as you noted would the likely make the project
dependent on the environment (paths, platform and such) in a nasty way.


On Wed, Dec 4, 2013 at 10:46 PM, John Gabriele <jgabriele@fastmail.fm>wrote:

> On Tue, Dec 3, 2013, at 12:49 PM, Dave Tenny wrote:
> > How can I express that I want my clojure project to run with java 1.7
> > jre/libraries?   It doesn't need to be compiled with 1.7, but I want to
> > ensure that the NIO2 libraries of Java7 are present if someone attempts
> > to
> > import the module and/or build the project with leiningen.
>
> Looks like you can set :java-cmd in your project.clj's defproject:
>
>     :java-cmd "/home/phil/bin/funky-java"
>
> If you want `lein` itself to start up using funky-java, I think you can
> set the JAVA_CMD env var, but I haven't tested it:
>
>     JAVA_CMD=funky-java lein version
>
> --
>   John Gabriele
>   jgabriele@fastmail.fm
>

Re: [leiningen] How to enforce java (runtime/library) version dependency?

From:
Phil Hagelberg
Date:
2013-12-05 @ 18:33
Dave Tenny writes:

> Yeah I was hoping for something more like a dependency like
> [com.oracle.java/jre "1.7.0"] or something like that.  However I can't
> imagine something like that working since there are no jre artifacts.  I
> just wondered if there was some semantic equivalent.

I recommend just checking it at load time.

    (when (#{"1.5" "1.6"} (System/getProperty "java.specification.version"))
      (throw (Exception. "Needs Java 1.7 or newer!")))

And then make sure it's clearly stated in the readme. It would be nice
to be able to catch it sooner, but practically speaking this will
accomplish the same thing.

-Phil

Re: [leiningen] How to enforce java (runtime/library) version dependency?

From:
Dave Tenny
Date:
2013-12-05 @ 20:37
ok, thanks, that'll do it I guess, just checking to see if there was
something cleaner and/or higher level.


On Thu, Dec 5, 2013 at 1:33 PM, Phil Hagelberg <phil@hagelb.org> wrote:

>
> Dave Tenny writes:
>
> > Yeah I was hoping for something more like a dependency like
> > [com.oracle.java/jre "1.7.0"] or something like that.  However I can't
> > imagine something like that working since there are no jre artifacts.  I
> > just wondered if there was some semantic equivalent.
>
> I recommend just checking it at load time.
>
>     (when (#{"1.5" "1.6"} (System/getProperty
> "java.specification.version"))
>       (throw (Exception. "Needs Java 1.7 or newer!")))
>
> And then make sure it's clearly stated in the readme. It would be nice
> to be able to catch it sooner, but practically speaking this will
> accomplish the same thing.
>
> -Phil
>