Hey all :wave: Can a plugin provide macros? We cur...
# general
a
Hey all 👋 Can a plugin provide macros? We currently have a bunch of useful macros that we want to share across multiple repositories, so I'm wondering if it's possible to provide those macros though a plugin?
b
I think a plugin can contain 'build file aliases', by defining a
def build_file_aliases() -> BuildFileAliases:
function in
register.py
, e.g.:
Copy code
def build_file_aliases() -> BuildFileAliases:
    return BuildFileAliases(
        objects={
            "foo": some_function,
        }
    )
It's a bit different to a macro, though, I think, as it has to work with the internal API for targets etc., rather than calling the external BUILD file ones. (NB. I could easily be wrong, it may be worth repeating the question in the lower-volume #C01CQHVDMMW channel, so people with the right knowledge are more likely to see it.)
c
Huon is correct, the macros are provided and configured from the project directly, there's currently no mechanism for a plugin to provide this. Build file aliases is an alternative but is slightly different as Huon points out.
a
Got it, thanks for the response @broad-processor-92400 @curved-television-6568
👍 1
I didn't find any docs about build file aliases at https://www.pantsbuild.org/docs. Am I looking at the wrong place?
c
no, you're right.. that part of the Plugin API is undocumented, so would need to go to the pants sources to find out how to use it..
👍 1
h
Could make sense to support macros shipped in plugins
👍 1
a
It would be pretty useful imo. Is there any reason why there isn't support for that yet?
h
Because you haven't added it yet? 😉
IOW, no important reason, just no one has done it yet.
a
Got it, thanks for the response.