Buck file aggregating multiple Buck files

550 views Asked by At

I structured my code in the following way:

BUCK
component A
  src
  test
  BUCK
component B
  src
  test
  BUCK

See an example here.

The BUCK file for each component looks like this:

java_library(
  name = 'selendroid-standalone',
  srcs = glob(['src/**/*.java']),
  visibility = [ 'PUBLIC' ],
  deps = [
    ...
  ],
  resources = [
    '//apps/selendroid-server-apk:selendroid-server-apk',
  ],
)

java_test(
  name = 'selendroid-standalone-tests',
  srcs = glob(['test/**/*.java']),
  deps = [
     ...
  ],
)

java_binary(
  name = 'selendroid-standalone-bin',
  deps = [ 
    ':selendroid-standalone',
  ],  
)

project_config(
  src_target = ':selendroid-standalone',
  src_roots = [ 'src' ],
  test_target = ':selendroid-standalone-tests',
  test_roots = ['test','test-resources'],
)

I want to be able to do:

$ buck build selendroid   # This should build everything
$ buck test selendroid    # This should test everything

My question is: What should the top-level BUCK file look like?

1

There are 1 answers

1
Simon Stewart On BEST ANSWER

In your .buckconfig file, add the following:

  [alias]
  selendroid = //path/to/some:target

You can only specify a single target in each alias, but that could be one that aggregates the sub targets you care about.

To run all the tests, use buck test --all