https://pantsbuild.org/ logo
r

rapid-bird-79300

08/26/2021, 4:18 PM
Trying to map all targets in a directory to a target dependencies. Following the docs here: https://www.pantsbuild.org/docs/targets#dependencies-and-dependency-inference Is there any way we can describe all targets in a directory instead of listed them out individually (something like
app/example::
)?
h

hundreds-father-404

08/26/2021, 4:34 PM
App/example: is a glob for all targets in a dir, but not subdirs. A single colon
r

rapid-bird-79300

08/26/2021, 4:38 PM
ahh okay I see. Is there any way to describe all targets under a specific directory (including sub dirs)
h

hundreds-father-404

08/26/2021, 5:11 PM
example::
is all targets in the dir and subdirs
r

rapid-bird-79300

08/26/2021, 5:41 PM
so when I try that I see:
Copy code
pants.build_graph.address.InvalidTargetName: Address spec app/example:: has no name part.
The BUILD file looks like this:
Copy code
python_tests(
    name="tests0",
    dependencies=[
        "app/example::"
    ]
)
h

hundreds-father-404

08/26/2021, 6:09 PM
Ah, to clarify, target globs only work on the command line. You have to be explicit in the
dependencies
field. If you find you're repeating yourself a lot, you can create a generic
target
as a "bag of dependencies" https://www.pantsbuild.org/docs/reference-target. Or implement a custom dependency inference plugin
1
r

rapid-bird-79300

08/26/2021, 6:13 PM
awesome that works thank you!
❤️ 1
5 Views