Search code examples
javaversioningpackage-managers

What is the proper way of maintaining a java module that includes java code, JSP pages, HTML, CSS, JS, and images?


I am very aware of package managers and versioning software. But while I have read docs and books on these subjects, my practical experience is very limited. So I apologize if the question itself doesn't make sense.

Maintaining a self-contained package vs versioning an application are both clear to me. However, what I wish to make is a 'base' application that colleagues can later copy, customize, and then check in as a new application, maintaining the ability to pull updates from the base application when updated.

It is my theoretical understanding that this can be done using branching, but it feels abusive, as the new applications are stand-alone and not really branches that are ever going to be merged. On the other hand, while it seems fair to me to make the application into a package of sub-packages, I have never seen java code being shared this way, and breaking the application into a package of front-end files and a group of JAR files feels all over the place.


Solution

  • You should divide your problem smaller problems ( divide et impera ), in particular try to understand MVC ( Model View Controller ) pattern ( see here https://it.wikipedia.org/wiki/Model-view-controller )

    What you can do with this parttern ? You can:

    • Model: define your dto / interfaces and package it into a module
    • View: define your pages / styles and package it into a module
    • Controller: define your controller and package it into a module

    Now, seems really abstract, but it's simple and you can do it as the following:

    • define a main project use maven/gradle
    • define a sub-project for model/views/controller
    • do your code
    • version and release your sub-projects into a company artifact repository ( like apache archiva as example )

    Doing so you can:

    • have one only code base
    • don't need branches
    • colleagues need only model? They add dependencies on that only, true for the other parts

    Problems:

    • you are building a webapp, and using MVC pattern you "slice" it horizontally, not vertically. So ask yourself: do I need to share all my work, or only part of it, like for example web components ?
    • if so, inform about microfrontends https://micro-frontends.org/
    • complexity: are you able to provide support for people using your artifacts ? For example new features, bugfixes ? Or "there is no time for this ?"
    • dependencies: there are external systems ( aka databases, rest/soap services, etc.. ) that your webapp depends on ?
    • documentation: if you want to share useable components, you need a proper documentation, otherwise people will ask to you for everything