Hey Pants Team, curious how we be able to extend e...
# general
r
Hey Pants Team, curious how we be able to extend existing targets to include new file extensions? For example, let's say we want shell sources to autogenerate for
.sh
and
.sh.tpl
. I see this doc https://www.pantsbuild.org/2.18/docs/writing-plugins/the-target-api/extending-existing-targets is the correct way to just extend the shell source value for for
expected_file_extensions
?
b
Some options that come to mind are setting
sources
on
shell_sources
targets by either: • using a macro wrapping it
shell_sources()
, like
def my_shell_sources(sources=["*.sh", "*.sh.tpl"], **kwargs): return shell_sources(sources=sources,**kwargs)
• setting
sources
with
__defaults__
, e..g
__defaults__({shell_sources: dict(sources=["*.sh", "*.sh.tpl"])})
I'm not sure either of those perfect. For instance,
pants tailor ::
won't create a
shell_sources
target within a directory that contains only
.sh.tpl
files.
c
Yea, as Huon points out, you'd just want to work with the sources value, as the shell backend doesn't use the expected file extensions feature as shell sources technically doesn't require them.
There's no way to get tailor to pick up on anything besides
.sh
sources, but I think using
__defaults__
is viable for your
shell_sources
to pick up your
.sh.tpl
files.
r
thank you for the suggestions! Fortunately this is only in one directory. I'm leaning towards creating one
shell_sources
target and globing all files from sub directories. It will be come painful since tailor can't be tuned for this