<@UH6670BHD> We've done this internally, I don't r...
# general
@loud-guitar-4381 We've done this internally, I don't remember the details, and I'm in the middle of a couple of things now, but ping me in a couple of hours and I'll look up how I did it...
👍 1
what we did was to run a pants subprocess to build jvm binaries then stitched them into the build graph
interested in however you ended up doing it too
We did something less hacky than that IIRC
🔥 2
ooooh, now i’m very interested
@happy-kitchen-89482 Hi. just wanted to see if you got a chance to look up the mechanism for doing this. thanks in advance.
Not yet, sorry. Crazy day. Remind me tomorrow morning?
np. sure
Hi @happy-kitchen-89482 just a friendly reminder on the above ^. thanks in advance.
@aloof-angle-91616 should weigh in on whether this makes sense, but as far as I can tell we called
in the task with a classpath that includes the just-compiled tool's classfiles
Which we find by:
Copy code
indexer_main_tgt = self.context.build_graph.get_target_from_spec('src/java/com/toolchain/asm/indexer')
classpath_products = self.context.products.get_data('runtime_classpath')
classpath = ClasspathUtil.classpath(indexer_main_tgt.closure(), classpath_products)
And we have a custom target type that injects a dep on the indexer, so that if the indexer gets modified the target is invalidated
yeah that's a lot better
i honestly cannot see an issue with that approach at all
the runtime classpath won't exist in, say, the gen phase
so that will work for tools that run after the compiler, but not before
v1 strikes again
i don't love our solution, but we should probably open source it.
I don’t understand the solution and looking for some clarification
I guess indexer is your jvm tool and located src/java/com/toolchain/asm/indexer
for example lets say I am running a task on a particular target for. eg: some_target:scala which doesn’t depend on indexer. how will the context.build_graph contain index target.
nvm, I understand it now. custom target type that injects a dep on the indexer
Thanks a lot @happy-kitchen-89482 for your approach.
not a great solution for me. I need to inject this jvm tool in every target in the codebase. This jvm tools contains custom scalafix rules for enforcing linting.
Yes, indexer is our custom tool
You can inject the jvm tool on every, say,
target in the codebase by subclassing JavaLibrary to inject the dep, then in your
you can point the
alias to your custom JavaLibrary.