Git branching model for client-server Java project

367 Views Asked by At

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. 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. Preferably there would be a git branch for each application (server & client) where each commit represents one release version (see my answer below). 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.

1

There are 1 best solutions below

0
On

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.

The master branch would contain all of the source code for the project (every package). 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). Once prepped for release, these branches would be rebased onto their respective release-client and release-server branches. 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):

My Git Branching Model