52

From Jigsaw Project:

Make it easier for developers to construct and maintain libraries and large applications, for both the Java SE and EE Platforms.

I'm trying to learn what project Jigsaw is and till now it seems that the goal of Project Jigsaw somewhat overlaps with what we did using Maven (or Gradle) dependency management:

  • Is it a threat to build tools like Maven?
  • Or my understanding is wrong and project Jigsaw is going to complement these build tools in some way?
Abhinandan Dubey
  • 655
  • 2
  • 9
  • 15
justAbit
  • 4,226
  • 2
  • 19
  • 34
  • did you see [this post](http://stackoverflow.com/questions/36583118/is-maven-ready-for-jdk9) and its answers to get some hints? – A_Di-Matteo Oct 04 '16 at 07:01
  • @A_Di-Matteo Yep, I have seen this answer but it seems more related to using JDK9 with Maven. It does not specify how dependency management in both are going to work together. – justAbit Oct 04 '16 at 08:41
  • 4
    Jigsaw is not overlapping Maven nor threaten cause they have something different in mind. Jigsaw is for modularisation (many similarities to OSGi) but for plain Java (SE) and EE. Jigsaw makes it easier to decouple modules which are only accesible via a defined interface which is defined in the module-info file and which is controlled by the javac compiler (jlink etc.) – khmarbaise Oct 04 '16 at 14:26
  • 3
    I am asking this question myself, except the word "threat" really throws this question off. What I think most developers want to know is: will this affect normal Java development with Maven-style dependencies? What benefits and changes are to be expected? – clay Sep 23 '17 at 02:20

2 Answers2

43

Very simplified answer

After Jigsaw, public will be public only within the JAR scope. To see the class outside the JAR it must be exported.

Java will force modularization because any inter module interaction will have to be specified in the module-info file.

For example, if you produce a WAR it will remain almost unchanged but all JARs packages in the WAR must define a module-info (or not define it and be treated as automatic or unnamed modules).

Maven has 2 main features: dependency management and building:

  • Dependency management means Maven can determine versions of libraries and download them from repositiories.
  • Building means Maven can compile code and package it into artifacts.

To conclude: Maven will still be responsible for building, but one must learn how to compile and package using Jigsaw modules.

JonyD
  • 1,237
  • 3
  • 21
  • 34
michaldo
  • 4,195
  • 1
  • 39
  • 65
  • 1
    It seems Jigsaw also manages dependencies via directives like `requires`. Does this part overlap with maven/gradle? What will be the proper way to do deps management for developers working on JDK 9 onwards? – wlnirvana May 11 '20 at 03:03
  • 1
    @wlnirvana for example, when one module `requires` second one, it means the second must be available on compilation and runtime classpath. Maven for retrieve library from repository, add to compile classpath and add to output war/fatjar/docker layer. About overlapping: there is no overlapping: `requires` is similiar to `import` - something is required to pass compilation/runtime, but how to get "the something" is build tool responsibility – michaldo May 11 '20 at 15:29
15

Modules are not in any way a threat to build tools. Modules complement build tools because build tools construct a dependency graph of artifacts and their versions at build time while modules enforce dependencies of artifacts/modules (not including versions) at build time and run time.

From the State of the Module System:

"A module’s declaration does not include a version string, nor
constraints upon the version strings of the modules upon which it
depends. This is intentional: It is not a goal of the module system
to solve the version-selection problem, which is best left to build
tools and container applications."
Jason
  • 7,356
  • 4
  • 41
  • 48