Respect the code base factor (from the 12-factor application manifest) for a Gradle / Spring application deployed on Cloudfoundry or Heroku

advertisements

My question relates to the first factor of 12 factor apps manifesto: the codebase. (see http://12factor.net/codebase).

My requirement: I have an website Spring application and a batch Spring application both sharing a common code i.e. the domain model (JPA entity classes). I need to be able to share this common code. And both applications need to use the same version of the common code at any one time.

My current setup: I have currently three "top-level" repositories on github:

  • Domain model (JPA entity classes) repo
  • Website application repo
    • Domain model directory/gradle project (included with git subtree pull/push)
  • Batch application repo
    • Domain model directory/gradle project (included with git subtree pull/push)

Please also note that the Domain model repo lives separately (as noted above) but is also nested within both the website and the batch application repos. I use a git subtree pull/push in order to include this Domain model repo as a directory and a gradle project within the other two repos. The reason for this is that Heroku builds the code itself from the repos.

All this is very tedious and error-prone.

Can someone please advise a better solution?


I would publish the common code to a private Maven repo on Bintray and then add that private repo to the other consumer apps and specify the common module as a dependency. This doesn't guarantee that both will depend on the same version but that could be easily managed through external processes using tools like the Maven Versions Plugin. But you also might want to add a more flexible serialization system to loosely couple the domain models of the two apps.