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

limited-insurance-37393

02/04/2022, 8:32 PM
When I'm running the
tailor
goal, is there some machinery that I can hook into to influence what targets get autogenerated into the BUILD files? For instance "For every directory with a
__main__.py
add a `python_distribution`"
f

fast-nail-55400

02/04/2022, 8:33 PM
You can write a plugin that hooks the
PutativeTargetsRequest
union. Then your plugin can return whatever targets it wants
tailor
to write out.
(This is in fact how the core
tailor
rules “know” about each language. Each language backend implements
PutativeTargetsRequest
for its own targets.)
l

limited-insurance-37393

02/04/2022, 8:37 PM
Great, thanks!
b

busy-vase-39202

02/04/2022, 8:45 PM
This is such a great tip.
PutativeTargetsRequest
isn't mentioned in the docs at all, or in the `example-plugin`repo. I think it is worth bringing up briefly in any of these: the docs, example repo, or as a short "tip" blog entry. @hundreds-father-404 thoughts?
h

hundreds-father-404

02/04/2022, 8:48 PM
yeah, it would be great to have that documented! In the meantime, check out this example: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/tailor.py
l

limited-insurance-37393

02/04/2022, 8:54 PM
Thanks, that's super helpful 🙂
3 Views