Add a Dependency on Another Target
You need to add a dependency for a library target in the same repository.
Add a reference to the desired library target to the
dependencies listed for
your target. Dependencies to other targets are typically added to
Below is an example
scala_library definition that specifies dependencies on other targets:
# myproject/src/main/scala/BUILD scala_library(name='scala', sources=rglobs('\*.scala'), dependencies=[ 'myproject/library-a', 'myproject/library-b:some-target' ] )
In this example, we have two dependencies, both of which reside in the same repository as our code. They are referenced by the relative path from the root of the repository, to the location of the
BUILD file that defines the buildable target you wish to depend on.
You should always target dependencies through their
other library target definition. Many projects have set up aliases that
are shorter. For more info, see
Create an Alias for a Target.
NOTE: In many cases, you can specify a library target path without specifying a target name. In the example above, the
myproject/library-a library is targeted without a target name. That's because the target name, in this case, is the same as that of the directory. Here's what that
BUILD file might look like:
# myproject/library-a/BUILD target(name='library-a', dependencies=[ # ... ] )
This is called a default target name and can be used whenever the target and directory names match.