Buck: buck suggest

buck suggest

The purpose of this command is to help you break down a large build rule into more fine-grained build rules. Currently, it only works with java_library rules.

To use it, run:

buck suggest //build/target/to:partition

Assuming this corresponds to a rule with the following definition:

java_library(
  name = 'partition',
  srcs = [
    # These four sources are in a diamond dependency.
    'Alpha.java',
    'Bravo.java',
    'Charlie.java',
    'Delta.java',
  ],
  visibility = [
    'PUBLIC',
  ],
)

Then buck suggest would print the following to standard out:

java_library(
  name = 'partition',
  exported_deps = [
    ':partition.Alpha',
    ':partition.Bravo',
    ':partition.Charlie',
    ':partition.Delta',
  ],
  visibility = [
    'PUBLIC',
  ],
)

java_library(
  name = 'partition.Alpha',
  srcs = [
    'Alpha.java',
  ],
  deps = [
    ':partition.Bravo',
    ':partition.Charlie',
  ],
  visibility = [
    'PUBLIC',
  ],
)

java_library(
  name = 'partition.Bravo',
  srcs = [
    'Bravo.java',
  ],
  deps = [
    ':partition.Delta',
  ],
  visibility = [
    'PUBLIC',
  ],
)

java_library(
  name = 'partition.Charlie',
  srcs = [
    'Charlie.java',
  ],
  deps = [
    ':partition.Delta',
  ],
  visibility = [
    'PUBLIC',
  ],
)

java_library(
  name = 'partition.Delta',
  srcs = [
    'Delta.java',
  ],
  deps = [
  ],
  visibility = [
    'PUBLIC',
  ],
)

In this particular case, the output from buck suggest could be used verbatim to replace the contents of the original BUCK file. However, the more common thing to do is to take the output and massage it into a level of granularity that is appropriate for your project.