Search code examples
androidgitsynchronizationandroid-manifestrepo

Can I extract multiple directories using local_manifest.xml from single repo?


I looked this and this thread but my question looks little different.

We've vendor provided embedded platform running Android 10. We want to create a separate repository on our local bitbucket server for following 3 directories,

  1. external
  2. kernel
  3. vendor

I've created local_manifests/local_manifest.xml and updated it with new project and remove-project tags accordingly.

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
   <remote name="bitbucket" fetch="URL" revision="mybranch"/>
   <default remote="bitbucket" revision="mybranch"/>
   <project name="device-kernel" path="kernel" revision="mybranch"/>
   <project name="device-external" path="external" revision="mybranch"/>
   <project name="device-vendor" path="vendor" revision="mybranch"/>
   <remove-project name="kernel/build"/>
   <remove-project name="kernel/configs"/>
   <remove-project name="kernel/kernel-5.10"/>
   <remove-project name="kernel/tests"/>
   ...
</manifest>

It looks like I need to have 3 git repositories to have them extracted into 3 different directories. e.g. device-kernel will store kernel and can be exported inside kernel directory using the path attribute.

Question: Can just create one repository and store 3 directories in it instead of 3 repos? If yes, then how? What I expect is with one repo it should export 3 directories in the same directory parallel to each other.

I would appreciate if your response has some reference xml or any reference article for same problem.


Solution

  • TL;DR Yes, In your case you can create one git repository and store your 3 directories in it. When repo sync is performed all 3 will be exported in the same directory.

    If you read carefully the 1st link, you can actually put path="." in your project tag to achieve above. It is ignored for local manifests. Notice following,

    “path” may not be an absolute path or use “.” or “..” path components. These restrictions are not enforced for Local Manifests.

    one more thing, your local_manifest.xml is missing the remote attribute in project tag though.