I have a spring boot project that contains a ‘core’ set of objects and then a set of different implementations that are similar but not. We’re using Gradle for build management and using tomcat for our web server and building our application into a war file.
Let’s say I have the following files in a single repository:
/src/main/java/com/mycompany/myproject/controllers/ProjectController.java /src/main/java/com/mycompany/myproject/dbmodel/ProjectEntity.java /src/main/java/com/mycompany/myproject/repositories/ProjectEntityRepository.java /src/main/java/com/mycompany/myproject/services/ProjectEntityService.java /src/main/java/com/mycompany/myproject/widgets/WidgetA.java /src/main/java/com/mycompany/myproject/widgets/WidgetB.java /src/main/java/com/mycompany/myproject/widgets/WidgetC.java /src/main/java/com/mycompany/myproject/widgets/WidgetD.java /src/main/java/com/mycompany/myproject/widgets/WidgetE.java /src/main/java/com/mycompany/myproject/widgets/WidgetF.java
During our sprint cycle, we change ProjectEntityService to add a new feature. All the widgets use this entity.
Now, separately, an issue is discovered in WidgetB.
Our goal is to be able to modify WidgetB and deploy it in such a way that we aren’t required to also deploy the new feature in ProjectEntityService. Currently we handle this with a hotfix branch. We’d eventually like to get to the point where the widgets are loaded using a custom classloader without having to reboot the system.
Currently I’m working through advanced Gradle features to figure out if I can separate the widgets into subprojects, so I could run, for instance
gradle :widgetA:build and have it just build the jar file for widget A. Then we could add a folder to tomcat’s classpath where we can deploy the widget jar files.
However, The ProjectController.java file depends on the Widgets and the Widgets depend on the ProjectEntity.java file.
I’m looking for some best practice ideas here on how to separate out the Widgets so that they can be deployed independently.
Another suggestion we’ve been floating is separating each widget into its own repository and including that repo as a submodule to the Project repository.
Does anyone have any suggestions on common approaches to this problem?