tools-build 2023-10-27

Hi, is it possible to target specific clojure version during compilation? Basically I need jre7 compatible class versions.

I'm not sure I understand your question but you can add :java-opts to specify source and target versions:

(compile-clj {,,, :java-opts ["-source" "7" "-target" "7"]})

Maybe I'm not getting it right, but tools build minimum clojure requirement is 1.10, so 1.10 is compiles down to jre8 class version (52). To make classes compatible with 7 I've only option to use compiler from clojure 1.9

I'm afraid my only option is not to use tools.build in this case, just wanted to clarify

I'm curious, what is forcing you to remain compatible with java 7?

enterprise customer

With bunch of win-xp machines. JRE8 is available for XP, but they sticked to jre7

Sounds a bit challenging! I guess you just have to go back in tooling a bit in order to support obsolete tech. How's that song go? "I'm gonna program like it's 1999!" simple_smile

Yep, its my life whole 2023 year :)

I send you a lisp hug: lisphug

❤️ 2
Alex Miller (Clojure team) 2023-10-27T13:40:08.832399Z

what matters here is the version of Clojure you compile with

@alexmiller is it possible with tools.build?

Alex Miller (Clojure team) 2023-10-27T13:42:09.554319Z

Clojure 1.9 was the last version to emit Java 6 bytecode (Clojure 1.10 switched to emit Java 8 bytecode)

Alex Miller (Clojure team) 2023-10-27T13:43:10.132939Z

because compilation happens in a forked process, I believe if you are using Clojure 1.9 or earlier in your basis, and Java 1.7 or earlier in your path, then the forked JVM for compile-clj should be emitting Java 6 bytecode

Alex Miller (Clojure team) 2023-10-27T13:43:49.890689Z

so, I think yes (have not tried it)

Ah ok, I tried that approach, failed with requiring-resolve not found. But I was running it from alias of deps.edn, I guess I need to run it externally

Alex Miller (Clojure team) 2023-10-27T13:46:37.559899Z

ah, requiring-resolve was added in 1.10 I think. you could copy and alter the compile-clj task code to do something slightly different

oh, good point

Alex Miller (Clojure team) 2023-10-27T13:48:03.842139Z

well where is that coming from? tools.build itself?

Alex Miller (Clojure team) 2023-10-27T13:48:32.528959Z

you can run tools.build with a different Clojure version than your project basis

yes clojure.tools.build.api

Ok, then I still have a hope, I've a wrapper tool around tools build, didn't want to discard it completely.

Alex Miller (Clojure team) 2023-10-27T13:50:34.559459Z

yeah, in your :build alias, just add a :deps of org.clojure/clojure {:mvn/version "1.11.1"} but then in your project deps, use "1.9.0"

🙏 1