https://pantsbuild.org/ logo
#general
Title
# general
h

happy-kitchen-89482

03/25/2019, 3:46 PM
@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
a

aloof-angle-91616

03/25/2019, 3:47 PM
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
h

happy-kitchen-89482

03/25/2019, 3:47 PM
We did something less hacky than that IIRC
🔥 2
a

aloof-angle-91616

03/25/2019, 3:48 PM
ooooh, now i’m very interested
l

loud-guitar-4381

03/25/2019, 9:02 PM
@happy-kitchen-89482 Hi. just wanted to see if you got a chance to look up the mechanism for doing this. thanks in advance.
h

happy-kitchen-89482

03/26/2019, 1:33 AM
Not yet, sorry. Crazy day. Remind me tomorrow morning?
l

loud-guitar-4381

03/26/2019, 1:34 AM
np. sure
Hi @happy-kitchen-89482 just a friendly reminder on the above ^. thanks in advance.
h

happy-kitchen-89482

03/26/2019, 9:01 PM
@aloof-angle-91616 should weigh in on whether this makes sense, but as far as I can tell we called
self.runjava()
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
a

aloof-angle-91616

03/26/2019, 10:32 PM
lmao
yeah that's a lot better
i honestly cannot see an issue with that approach at all
w

witty-crayon-22786

03/26/2019, 10:37 PM
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
a

aloof-angle-91616

03/26/2019, 10:37 PM
v1 strikes again
w

witty-crayon-22786

03/26/2019, 11:07 PM
i don't love our solution, but we should probably open source it.
l

loud-guitar-4381

03/27/2019, 2:28 AM
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.
h

happy-kitchen-89482

03/27/2019, 6:00 PM
Yes, indexer is our custom tool
You can inject the jvm tool on every, say,
java_library
target in the codebase by subclassing JavaLibrary to inject the dep, then in your
register.py
you can point the
java_library
alias to your custom JavaLibrary.