Think in a world in which you are alone, you are not depending of anyone, you
do not need anything other than yourself, you can do your task and survive only
on your own. If you like that, then you can do only few things on your life.
A Java Project doesn't work alone
Build a Java Project might seem
simple, it is needed to compile the Java classes and get the functionality in a
.jar. However, in other cases, like a larger Java Project, which is using a lot
of different projects as dependencies, is more difficult to handle because
these other projects have their own versions. If there are many projects
working together, each with their versions and dependencies chain, then
automatize this is needed. Time can not be wasted on repetitive task, the concern
is to write code. And good code is needed.
Java Projects together are Stronger?
Someone can say "To manage my project without depend on anybody, I
will place all java classes into a single project". Someone can do this,
and can do whatever you want, but it will violate all good practices and design
recommendations and it will be a messy project that nobody will be able to
maintain because it is not separated in component with different purposes.
When a smarter project is built using a little of common sense, this
project will have a purpose and it has one responsibility. In this case, there
are several projects working together, each of them knows what projects need to
get its job. They are not working alone and when it is needed to fix something
or add a new feature, then it will be easier to know where to start coding.
Your design makes sense now?
Maven takes the control project's life
Maven can help when there is a Java project and repetitive task such as
versioning and dependency management, which can become a headache. The names of
the projects and the version are specified only once, and the team is concerns
in to code or other more important activities. Likewise, the project coded also
has version, then it can be referenced by others.
If this project is build using other projects that are being coded, then
everyday you can get the last updates of these dependencies. You can be sure
that everything is working fine and the last update of the current version
(Snapshot) is doing the expected work.
Maven works with repositories, which contain the .jar projects
needed and downloaded. Exists other repositories where the jar is
deployed, the developers are not working alone, and everyone has to work with
the latest version of all.
Maven uses simple commands to build an entire project, these are repetitive
and follow some standards like folder structure where is the code, test,
resources, etc., the issues to manage the project are reduced.
The java code is used to get the functionality and the pom xml is
used to manage the project, that file is what Maven understands, this is the
project itself.
It is more than that
Maven plugins are use with different intentions. They can
be used to run tests, deploy to a server, generate reports, etc., there are
many of them and always are added more. An own plugin can be created.
The archetypes allow to build a War, an Ear and a Jar project among many
others, it can be added with Spring, JSF or another technology, only using a
simple command. Start coding in a new project rapidly, seeing their results, is
easier. In the case in which, there is not needed to follow the same structure
of the archetype, is allowed to change the project structure because the pom
generated can be modified.
Like their projects, Maven is not working alone
There is an Open Source community that is integrating Maven with other
technologies such as Hudson that needs to build project and run the automation
test. Also uses plugins to deploy automatically a project on a server and has
much more things to offer.
Maven has disadvantages too, here are some of them:
- The
pom file can be very large. If the project uses many dependencies and
plugins, then there is no way to separate this.
- Two
dependencies of a project may need the same dependency, but with different
version. Transitive dependencies are harder to handle
- A
dependence that doesn't compile can need other dependences (transitive
dependence) and is needed to update and compile it in the case that is
under build.
- The
build cycle can be slow, but its steps are necessary. It needs to download
all dependencies, compile, run tests, install and deploy. Some steps can
be ignored if it is needed.
Maven manages the life of a project. It has some deficiencies, but it makes
its work and does it well.