The following will print all build targets in the project (sorted alphabetically) to standard out:
buck targetsThis command can be handy in programmatic tasks, such as running all of the Java tests under
buck targets --type java_test | \ grep '//java/com/myproject' | \ xargs buck test
A list of rules can also be passed into
buck targets and Buck will only print out target information for those rules. For example:
buck targets --show-output //java/com/myproject:binary > //java/com/myproject:binary buck-out/gen/java/com/myproject/binary.apk
--typeThe types of target to filter by. For example:
buck targets --type java_test java_binary
--referenced-fileFilters targets by the list of rules that include
referenced-filein their transitive closure.
For example, if a developer wanted to run all tests that could be affected by particular file, they would run:
buck targets --type java_test \ --referenced-file java/com/example/Foo.java | xargs buck test
--jsonPrint JSON representation of each target.
In addition, the JSON includes the list of 'direct_dependencies' for each target, which may include additional dependencies for targets whose descriptions implement ImplicitDepsInferringDescription. The fully qualified names of targets are given.
For example, when resolving a genrule, the direct dependencies includes both the build targets in 'deps' as well as any build targets in a script associated with the genrule.
--output-attributesSpecify attributes used in JSON representation.
Omitting this option results in showing all attributes.
--print0Delimit targets using the ASCII NUL character (when
--jsonis not specified). This facilitates use with
buck targets --print0 | xargs -0 buck build
--resolve-aliasPrint the fully-qualified build target for the specified alias[es]. This command also accepts build targets. See
.buckconfigfor more information.
--show-outputPrints the relative path to the output for each rule after the rule name.
--show-target-hashPrints each rule's target hash after the rule name. A target hash is created by finding all of the transitive dependencies of the given target and hashing all of their attributes and files they reference. For more details about how the referenced files are hashed see the
--target-hash-file-modeflag. The format of the data that is hashed is undocumented and can change between Buck versions. Target hashes can be used to detect which targets are affected when source files of BUCK files change: if a target is affected, its target hash will be different after the change from what it was before.
--target-hash-file-modeModifies how target hashes are computed. Can be either
PATHS_ONLY. If set to
PATHS_AND_CONTENTS(the default), the contents of all files referenced from the targets will be used to compute the target hash. If set to
PATHS_ONLY, only files' paths contribute to the hash.
PATHS_ONLYwill generally be faster because it does not need to read all of the referenced files, but it will not detect file changes automatically. See
--target-hash-modified-pathsfor another way to handle changes to referenced files without losing the performance benefits.
--target-hash-modified-pathsModifies how target hashes are computed. This option is only effective when
--target-hash-file-modeis set to
PATHS_ONLY, otherwise the actual contents of the files are used to detect modifications and this option is ignored. If a target or its dependencies reference a file from this set, the target's hash will be different than if this option was omitted. Otherwise, the target's hash will be the same as if this option was omitted. This option can be used to detect changes in referenced files if the list of modified files is available from an external source, for example a source control system.