When I'm running the `tailor` goal, is there some ...
# general
l
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
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
Great, thanks!
b
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
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
Thanks, that's super helpful 🙂