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.
My Solution
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, themaster
branch would be rebased onto areleaseprep-client
orreleaseprep-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 respectiverelease-client
andrelease-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):