Organize multi-app project with share code

梦想的初衷 提交于 2019-12-08 08:17:41

问题


I have a serious problem (!!!) about organizing my develop environment;

I have two apps: app1 and app2. This apps are written using OpenUI5 (but this detail is not important)

app1 and app2 are similar and share some code (for example the code to login). I use git (with git-flow) with two remote repo and I have all equal code duplicate. Now I want optimize my develop-flow sharing equal code (login code).

This is my first idea: have only one repo contains all my code in a structure of this type:

repo
|_____share
|     |____login.js
|
|_____app1
|     |_____index.html
|     |_____resources
|           |_________util1.js
|_____app2
      |_____index.html
      |_____resources
            |_________util2.js

I have two time state:

  • DEVELOP time where each index.html uses resources/utilX.js and ../share/login.js
  • RELEASE time where each index.html uses resources/utilX.js and resources/login.js

Good! I can create (using grunt?) a RELEASE for each app; for example the result of RELEASE is

app1
|_____index.html
|_____resources
      |_________util1.js
      |_________login.js.js

I can push app1 folder to my server and it works fine!

But now I have some doubt:

  1. Using git-flow I have master and develop branch; with only one repo I have only one mastes and consequently when on app1 I want to do a release I must tag the full master with a new release. I don't like it, I would like two apps with their own number version
  2. Is better have two separate repo (repo_app1 & repo_app2)? And in this case where are the share files?
  3. In other (compiled)language I can create release version whit only compiled files of an app. Grunt is the right way to prepare the app folder to push on my server?

回答1:


Git Submodules might be helpful for you. It will allow you to move app1, app2 and shared code to different repos and then inject shared code repo to your app repos. For more information read documentation




回答2:


An other solution could be to use subtrees.
It allow to share code between projects, typically in case of dependencies, and it allows to communicate in both directions:

  • You can modify your shared code and decide to integrate it in app1 or app2 at different times, each of them are completely independent.
  • In the same way you can perform modifications of shared code in app1, push it to shared code repository and decide later to integrate it in app2

The official documentation is here :
http://www.git-scm.com/book/en/v1/Git-Tools-Subtree-Merging

A great tutorial performing submodules vs subtree comparison with detailed explanations could be found here :
http://typecastexception.com/post/2013/03/16/Managing-Nested-Libraries-Using-the-GIT-Subtree-Merge-Workflow.aspx



来源:https://stackoverflow.com/questions/30398623/organize-multi-app-project-with-share-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!