Facing issues in Bazel build when trying to Integrate one repository as a remote repo to another repository

365 Views Asked by At

We have a repository which uses bazel build, Folder structure is such that remote_repo -> source -> BUILD we have added target in BUILD file like //source:target (starts from root folder) This works fine when we run Bazel command in remote_repo

Now this repository is added as a remote repo to another repository in git in the form of submodule. Folder structure is like actual_repo -> applications -> our_application -> remote_repo -> source -> BUILD When I try to compile actual repo which has its own BUILD file and remote repo BUILD is added as dependent target, am getting error: as no package found at source (//source:target starts from root, it is not able to find target).

How to resolve such an issue?

2

There are 2 best solutions below

0
On

The problem here is, that you now have to use a longer path like //applications/our_application/remote_repo/source:target as target labels are relative to the WORKSPACE root.

Another option would be to include the submodule as a local_repository() and referencing your target as @remote_repo//source:target (given you've named the repository accordingly).

0
On

By making the relative path as //applications/our_application/remote_repo/source:target and building remote repo in own applicatio i am getting below error: no such package '@remote_repo//application/own_application/remote_repo/src': BUILD file not found in directory 'application/own_application/remote_repo/src' of external repository @remote_repo. Add a BUILD file to a directory to mark it as a package. and referenced by '@remote_repo//:remote_repo'