16
Besides the fact that Maven works with jars and Java 9 with "modules", what is the difference between the modularization system of the two?
Why would I stop modularizing my systems with Maven to modularize with Java 9?
16
Besides the fact that Maven works with jars and Java 9 with "modules", what is the difference between the modularization system of the two?
Why would I stop modularizing my systems with Maven to modularize with Java 9?
4
In a very simple way, the difference is:
Maven manages dependencies Compile-time. Maven makes it easy to build the software. Not only when compiling, but also when testing, packaging and distributing the software.
Java Platform Module System manages dependencies run-time. Only used at runtime in JVM (Java virtual machine).
Interesting that even the class documentation Module
underscores this. https://docs.oracle.com/javase/9/docs/api/java/lang/Module.html
Represents a run-time module, either named or unnamed.
In short, each system acts at different times. Be sure to use Maven.
BONUS QUESTION: Why would I stop modularizing my systems with Osgi to modularize with Java 9?
REPLY: Continue using Osgi, Java 9 does not understand module versioning.
"ANSWER: Continue using Osgi, Java 9 does not understand module versioning." - But he’s here to stay, for better or for worse. Soon, there will be cases where projects will have to use both libraries published in module format and those in Osgi. And I see that what’s going to happen is that the new libraries will come out in both formats, but still many old libraries will take years to update.
I spent Friday reading the Java 9 Release Numbers. I fear that migration will complicate the lives of many people. I hope that Java 10, or 18 or 2018 (because they want to change the version of Java) will improve the situation of the people. But we cannot wait long. :(
2
Modules are separate code libraries that are added to the project as dependency. As a final result, we have a project composed of several modules that run on top of the traditional Java Runtime (JVM).
The modules consist of smaller parts of the Runtime, specific to the needs of the project. This innovation will enable a great performance improvement for applications, especially those that run on devices with low processing power
Good, but that’s exactly what I meant Besides the fact that one works with jar and the other with module :I think (almost sure) that there is much more out there hehe
-2
This post brings an important consideration to your question, and in my view also answers it:
"Maven modules are a way to organize your project into several subprojects (modules). With Maven, you can control the versions of These modules and the dependencies between These modules. Each module will Produce an Artifact. Java modules are a way to strongly encapsulate your classes. It does not provide any Means to control the version of an Artifact you are using. So, Maven modules and Java modules serves a Different purpose. The confusing part is that the same term module is used while they represent Something Different. But as long as we know the Difference, this should not be a problem"
"Modules in Maven are a means of organizing your project into subprojects (modules). You can control the versions of these subprojects as well as the dependencies between them. Each subproject will produce an artifact. Java modules are a means of tightly encapsulating your classes, they do not provide any means of controlling the versions of artifacts that your application uses, then, Maven modules and java modules serve different purposes. What can confuse is the same term (module) to be used to represent different things, but, knowing to distinguish, this should not be a problem"
It would be interesting to post the translated excerpt in your reply.
Good suggestion @Pedrogaspar!
Browser other questions tagged java maven java-9 jigsaw
You are not signed in. Login or sign up in order to post.
I liked the question and I will search for an answer. Basically Maven is what already exists and Java 9 is what came to organize things. But, both are criticized quite heavily and both have serious deficiencies.
– Victor Stafusa
Java 9 was officially launched today and we still don’t have an answer to this question. To "celebrate" the launch, I’m giving 100 dots to anyone who gives a good answer to this question within the next 7 days!
– Victor Stafusa
I saw a video of the Maven guy talking about it. A module will continue to exist inside a jar, so Maven will import this jar. The modules if I am not mistaken serve to define which parts will be opened and which need to be received from which module provider
– Jefferson Quesado