Issue
I know core Java, I want to learn Maven/Gradle. But I want to know why maven or gradle is required. is there any way to understand the problem we would face without maven or gradle. I want to know the procedure to build it without using build tools. A technology emerges for solving any issue. I want to know the issue Java developers were facing.
Solution
Why Maven or Gradle come into picture?
Because building non-trivial applications by running javac
from the command line leads to mistakes, non-reproducible builds and so on.
The history is roughly as follows
- Running
javac
by hand is tedious and unreliable. - Shell scripts that run
javac
etc are cumbersome, and a maintenance burden. Make
came next1, but Make didn't understand Java, so you ended up recompiling a lot of Java classes unnecessarily.- Then came
Ant
, but that didn't understand Java library dependencies. (That lead to the practice of embedding copies of JARs for dependencies into the repositories of the projects that use them. And consequent difficulties.) - Then came
Maven
which provided a system to describe and manage dependencies. Also it introduced a standard way of structuring the code and non-code files in a project. - Then came
Gradle
which has a more flexible (non-linear) model of how tasks are performed. And performance. - Then came
Bazel
which is more focused on reproducibility of builds.
The differences between Maven, Gradle and Bazel are more pronounced for large projects.
1 - "Next" in terms of its use for Java builds. The Make tool itself predates Java by many years.
Answered By - Stephen C
Answer Checked By - Robin (JavaFixing Admin)