javamavenmulti-modulejava-modulejava-platform-module-system

Difference between multi-module (pom) and java module system


I'm trying to understand the difference(s) between structuring a project with the Java Platform Module System (JPMS) versus structuring a project using multi-poms.

Is the main difference that the JPMS encapsulates the code while a multi-pom project separates project dependencies?

I've searched on google but I haven't found a good explanation on the differences, but rather I see the word module getting used interchangably.


Solution

  • The computing industry often recycles terms. Context is everything.

    The two kinds of “module” you present are unrelated, orthogonal issues.

    Very simple apps in Java may use neither.

    I can see how you could become confused, as both have to do with arranging classes. To oversimplify, Maven modules are about compile-time (dependency management and build automation) while Java Platform Module System is about runtime (limiting access to classes, encapsulation).


    I’ve read that Gradle is more adept at managing a multi-module project. You might consider switching from Maven to Gradle for your multi-module projects. Gradle obtains your dependencies from Maven repositories.


    You asked in a Comment:

    if you had to split up a monolith legacy app that is really several apps rolled into one, would you take a mutli-modual approach or JPMS approach?

    Again, project-modules and JPMS are orthogonal issues.

    You could modularize with JPMS either before or after splitting your legacy app project into separate app projects.

    Regarding project structure: