so...i stopped working on this for a few days and ...
# plugins
f
so...i stopped working on this for a few days and knowledge has left my head! I was planning on adding loose files to my docker plugin, with a
files
field included in the fieldset, but I'm no longer sure what rule transitions i need to go through to get there. I remember I had found the source of a rule in the pants repo that was really similar to mine that I was adapting, but I can't find this anymore. I thought it was the
archive
rule but it doesn't look like what I want. Any help I can get to lead me in the right direction?
h
I think it would be the
archive
target. That target has a
files
field and a
packages
field. Both subclass
SpecialCasedDependencies
This is in
core/target_types.py
🙏 1
f
ah yes,
package_archive_target
👍 1
what's the deal with the
HydratedSources
? is that only for code generation?
h
Regardless of codegen or not, you use
Get(HydratedSources, HydrateSourcesRequest)
or the convenience
Get(SourceFiles, SourceFilesRequest)
to get a digest for source files. The only reason I used
HydratedSources
there, rather than
SourceFiles
, is to avoid a possible import cycle with
core.util_rules.source_files
. For you, you can replace the
MultiGet(Get(HydratedSources))
with
Get(SourceFiles)
- they do the same thing We set
enable_codegen=True
in case any plugin authors wrote plugins that generate
FilesSources
. (Pants itself uses codegen for the
relocated_files
targets, which only only works if the callsite sets
enable_codegen=True
). Because we enabled codegen, we also need to say what types of sources we’re getting back. This is so that, for example, a Python test doesn’t result in Java sources getting generated, which it doesn’t use. Pants only generates what is relevant. https://www.pantsbuild.org/docs/rules-api-and-target-api#the-sources-field
👌 1