hi 👋 . i’m writing a simple tailor rule that adds some targets if they are missing, and that works well. my rule enumerates the owned sources, computes a set difference to find unowned sources, and returns https://github.com/pantsbuild/pants/blob/2505e54f2d8dde4f509caa7749de5ab8ae1de450/src/python/pants/core/goals/tailor.py#L260 putative targets which are then added to the build file if they were absent. reading through the implementation, in particular around https://github.com/pantsbuild/pants/blob/2505e54f2d8dde4f509caa7749de5ab8ae1de450/src/python/pants/core/goals/tailor.py#L661, I see that when I do return a putative target with the same name as an existing target, the conflicted one is renamed and appended instead of having a replacement occur. based on this, it looks like there isn’t a way to replace the definition of a target in a BUILD file with the tailor goal. is that understanding correct? is there a different rule set or builtin that would be more appropriate to do this per target modification as opposed to appending? thanks. 🙏
c
curved-television-6568
05/08/2024, 7:00 PM
Perhaps not exactly what you’re looking for, but there are “update build files” rules for fixing deprecated names (targets and fields) in build files that could be used for inspiration perhaps..