https://pantsbuild.org/ logo
f

fast-nail-55400

03/09/2022, 10:32 PM
is there any way to filter a list of
ClasspathEntry
down to just those generated from a
jvm_artifact
?
context: exposing third-party deps in BSP
a

ancient-vegetable-10556

03/09/2022, 11:03 PM
Not immediately, @fast-nail-55400. I would not object to adding a
provenance
field to
ClasspathEntry
to facilitate that though
and then each thing that produces a
ClasspathEntry
can mark what produced it
(presumably it’d be a
type[ClasspathEntryRequest]
)
f

fast-nail-55400

03/09/2022, 11:04 PM
I’d also need to extract maven coordinates from the ClasspathEntry
this all assumes that using
ClasspathEntryRequest
to find this data is the right way to do it
w

witty-crayon-22786

03/09/2022, 11:13 PM
could flip it around and filter to things that you know are
jvm_artifacts
, and then request entries for them
f

fast-nail-55400

03/10/2022, 12:22 AM
I thought about that and played with some code to do so but it gets complicated. The code needs request transitive targets from a
CoarsenedTarget
by using
TransitiveTargetsRequest
on the members of the
CoarsenedTarget
— then convert them back to
CoarsenedTarget
in order to use
ClasspathEntryRequest.for_targets
— the back and forth seems pointless for want of a better API
versus having a way to classify a
ClasspathEntryRequest
and filter out the ones not needed. may even be a way to implement classpath scopes eventually.
(assuming for the sake of this idea that scope was associated with the
jvm_artifact
and not the dependency edge)
w

witty-crayon-22786

03/10/2022, 12:39 AM
after requesting the classpath entry is too late to filter by scope i think… would want to filter sooner
otherwise you’re building things you don’t need
but haven’t thought about it much.
f

fast-nail-55400

03/10/2022, 12:41 AM
hmm good point. will need more thought then.
back to getting just jvm_artifacts, maybe there needs to be a
for_classpath_entry_request_types=
attribute like what codegen has with
for_sources_types
(the context here is scala/java BSP rules on top of https://github.com/pantsbuild/pants/pull/14750 )