0

Is it possible to have an external repo inside the App repo and be able to update codebase of that external repo directly from Android Studio, just like one is able to do with pods in xCode?

I know about submodules but this seems like much hassle with many many problems (like refactoring)

I have a repo which contains some utility commons which are used by every version of rebranded App. Right now this is cloned in every app separately and when something is updated in those utils I need to update it in every rebranded app manually.

I would like to be able to update this utility repo from the App project I actually work on, and the changes should be automatically visible in every App that uses this repo.

Is this possible?

laszlo
  • 494
  • 4
  • 18
  • Usually you'd create a separate repo of your utility, then create a hard link in your project, then add the hard-linked directory to your project's gitignore. But this is pretty complicated and dangerous, because your repo no longer contains all of the code you need to build your project. Should the other repo ever get lost for some reason ([which happens](https://about.gitlab.com/2017/02/10/postmortem-of-database-outage-of-january-31/)) you might have serious trouble building your project. Also, getting new devs setup can be achingly slow and buggy. – JDB Oct 25 '17 at 14:10
  • 1
    The industry-wide consensus is that single, mono-repos are better. That might change at some point in the future, but if [Google is using a mono-repo](https://research.google.com/pubs/pub45424.html) then I think you might want to give it some serious consideration. (My company tried the multi-repo approach and, after several months of floundering, switched to mono-repo. The issues with multi-repos just keep piling up.) – JDB Oct 25 '17 at 14:12
  • Could you provide some examples of problems with that approach? – laszlo Oct 25 '17 at 14:22
  • 1
    One problem is that you lose the ability to control which version of the utility your project uses. If the utility is updated, and your project isn't ready for that updated utility (breaking changes, etc), then you'll either be scrambling to fix stuff or you'll have to have a team consensus about which commit of the utility to have checked out, etc. In my company's case, we had major issues around PRs that needed to merged simultaneously to multiple repos... if a project PR was merged before/after the utility PR, dev/master would be broken for a while. – JDB Oct 25 '17 at 14:29
  • "I know about submodules but this seems like much hassle with many many problems (like refactoring)" -- library modules is how pretty much every library for Android is distributed. Most of those `compile` lines in your `dependencies` closure in `build.gradle` are pointing to AARs created from library modules. So, library modules work for lots of other developers, both on the creation and the consumption side. – CommonsWare Oct 25 '17 at 14:49
  • But I still can't update my dependencies when using them with `compile` can I? I mean submodule as here https://archie94.github.io/blogs/working-with-submodules-in-git-and-android-studio or here https://johnleach.co.uk/words/2008/10/12/git-submodules-in-n-easy-steps/ – laszlo Oct 25 '17 at 15:06

1 Answers1

1

Use submodules on the opposite side will save your energies.

Since all the App repos are depended on the utility repo, and it should update the dependencies once the utility repo updated, so you can treat the utility repo as the main repo, and all the App repos as submodules for the utility repo. So the structure will be:

Utility repo
      |____App repo1
      |____App repo2
      |____...
      |____App repoN
      |____...

And all the code of different apps and the utilities are managed separately, while all the App repos will get latest dependencies when utility repo updates.

Note: you can refer the two post here and here for add dependencies from the App external directory

Marina Liu
  • 36,876
  • 5
  • 61
  • 74