Fork me on GitHub
#graalvm
<
2022-07-07
>
wombawomba09:07:24

Is there a way to have compile-time-only dependencies and code when building native images? I'd like to precompute some stuff that requires dependencies and code that I then don't use in the final build.

borkdude09:07:10

Can you give an example?

wombawomba09:07:18

Sure. I'm extracting and precomputing some data from the commits in my repository using https://www.eclipse.org/jgit/

wombawomba09:07:53

I need the data in the executable, but not the code to produce it

borkdude09:07:19

Maybe just spit that out as an .edn file and then include the .edn file as a resource?

wombawomba09:07:39

though about it, but I'd rather not

wombawomba09:07:00

when developing I want to be able to run the computation continuously

wombawomba09:07:15

I mean, whenever I need it

wombawomba09:07:36

and sticking it in a resource means I'd have to recompute/reload it manually

borkdude09:07:06

you could do it in a macro which runs at compile time and the compiled bytecode would contain the result

wombawomba09:07:21

yeah that'd be ideal

borkdude09:07:46

but since eclipse git stuff probably uses security stuff, I'd expect that you would not be allowed to do this at build time, but worth a try

wombawomba09:07:54

I'm wondering how I would actually structure my code so that the dependencies don't get pulled in

borkdude09:07:59

I would probably not use eclipse git stuff at all, just shell out to git instead

wombawomba09:07:10

yeah, can't do that

wombawomba09:07:41

if I make my macro call a function, will that function get compiled in?

wombawomba09:07:55

i.e. would I have to stick all the code in the macro?

wombawomba09:07:13

...and if I do that, would graalvm still build the jgit classes I (:include) into the native image?