Hi folks! Coming from Bazel, I'm used to being abl...
# general
l
Hi folks! Coming from Bazel, I'm used to being able to build any target. Is there something similar in Pants? For example with this
shell_command
Copy code
shell_command(
    name = "foo",
    command="echo 'foo' > bar.txt",
    tools=["echo"],
    output_files=["bar.txt"],
)
How can I develop this target? How do I run the target and get the contents of
bar.txt
? I tried this so far • pants peek //:foo • pants run //:foo • pants package //:foo • check
.pants.d
directory • check
dist
directory But none of these worked out so far
1
Or by adding the
:foo
target into an archive:
Copy code
archive(
    name = "archive",
    format = "zip",
    files = [
        ":foo",
    ]
)
And running
Copy code
pants --keep-sandboxes=always package //:archive
Also doesn't give me the location of the
bar.txt
file. Reading Tips and debugging I guess the files are stored in
~/.cache/pants/lmdb_store
but particular store doesn't maintain file names.
Ah I've found it I think!
Copy code
pants export-codegen //:foo
This will write out the file to the dist directory 🎉
Sweet! Expected this to be something simple 🙂
f
right, normally Pants treats generated code as an internal byproduct, and doesn't expose it. But you can run the
export-codegen
goal to generate code to a well-known output location for consumption.