简体   繁体   English

客户端-服务器Java项目的Git分支模型

[英]Git branching model for client-server Java project

I have a Java project that uses a common set of code in two main applications that need to be distributed: a server, and a client. 我有一个Java项目,该项目在需要分发的两个主要应用程序中使用一组通用代码:服务器和客户端。 The project is organized into the following packages and each application requires the packages as indicated. 该项目被组织为以下软件包,每个应用程序都需要如所示的软件包。

           Packages           | Client |  Server  
------------------------------+--------+---------
com.example.game.server       |  No    |  Yes
com.example.game.client       |  Yes   |  No
com.example.game.core         |  Yes   |  Yes
com.example.game.core.physics |  No    |  Yes
com.example.game.ui           |  Yes   |  No
com.example.game.utils        |  Yes   |  Yes
com.example.game.networking   |  No    |  Yes
org.library.sourcecode        |  Yes   |  Yes

I would like to distribute the client and the server as jars with only the relevant packages for the respective application included, and not include any unnecessary code. 我想将客户端和服务器作为jar分发,仅包含与各个应用程序相关的软件包,而不包括任何不必要的代码。 Preferably there would be a git branch for each application (server & client) where each commit represents one release version (see my answer below). 最好每个应用程序(服务器和客户端)都有一个git分支,其中每个提交代表一个发行版本(请参阅下面的答案)。 All of the commit history for the project as a whole (server + client) should be tracked together (meaning one "development" branch with all the code in it?). 应该一起跟踪整个项目(服务器+客户端)的所有提交历史记录(意味着其中包含所有代码的一个“开发”分支?)。 How can I do this? 我怎样才能做到这一点?

Please note that I would not like to use more than one repository since the client & server code is so closely tied together, and it should be handled in git together. 请注意, 我不希望使用多个存储库,因为客户端和服务器代码是如此紧密地捆绑在一起,应该在git中一起处理。

My Solution 我的解决方案

This is my solution to the problem; 这是我解决问题的方法; however, this seems very cumbersome and difficult to follow through with. 但是,这似乎非常麻烦且难以执行。 My project is much more intricate and bigger in scale than the example, and this doesn't seem like a good practice solution. 我的项目比该示例复杂得多,规模更大,这似乎不是一个好的实践解决方案。

Note that I am not an expert with Git by any means. 请注意,我绝不是Git的专家。

The master branch would contain all of the source code for the project (every package). master分支将包含该项目的所有源代码(每个程序包)。 Regular development commits would be made to this branch, and feature and hotfix branches would be merged onto this one. 将对该分支进行常规开发提交,并将功能和修补程序分支合并到该分支。 Once ready for release, the master branch would be rebased onto a releaseprep-client or releaseprep-server branch which would serve as a midpoint where the unnecessary packages for the respective application would be deleted and it would be prepped for release (no features should be added). 一旦准备好发布,则master分支将重新建立到releaseprep-clientreleaseprep-server分支上,这将作为中间点,在该中间点,将删除相应应用程序的不必要软件包,并准备将其发布(不提供任何功能)添加)。 Once prepped for release, these branches would be rebased onto their respective release-client and release-server branches. 一旦准备好发布,这些分支将重新基于它们各自的release-clientrelease-server分支。 Each commit on these "release" branches would represent a production-ready state of the application and would be tagged with the version number. 这些“发行”分支上的每次提交都代表应用程序的生产就绪状态,并用版本号标记。

Here's a graphic to better understand (I'm a programmer, not an artist): 这是一个更好理解的图形(我是程序员,而不是艺术家):

我的Git分支模型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM