tools-build

armed 2023-10-27T11:27:04.475749Z

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

Kirill Chernyshov 2023-10-27T12:00:28.503709Z

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"]})

armed 2023-10-27T12:10:44.012209Z

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

armed 2023-10-27T12:43:11.229159Z

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

lread 2023-10-27T12:55:35.443929Z

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

armed 2023-10-27T12:56:03.788349Z

enterprise customer

armed 2023-10-27T12:57:57.274539Z

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

lread 2023-10-27T13:14:47.311019Z

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

armed 2023-10-27T13:15:33.017599Z

Yep, its my life whole 2023 year :)

lread 2023-10-27T13:16:33.234399Z

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

armed 2023-10-27T13:40:58.928019Z

@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)

armed 2023-10-27T13:45:08.152109Z

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

armed 2023-10-27T13:45:13.455499Z

Thanks, Alex

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

armed 2023-10-27T13:47:23.502779Z

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

armed 2023-10-27T13:48:56.513349Z

yes clojure.tools.build.api

armed 2023-10-27T13:49:39.065239Z

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