An introduction to Maven

24 Abr

We have seen Maven in other posts (Basic Hibernate example with Apache Derby and Maven or Primeros pasos con Spring Android). To have a better idea of how Maven works I’m going to write a little introduction about Maven.

What is Maven?.

The Apache Maven project defines Maven as:

a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.

Maven goals are as follows:

  • Making the build process easy.
  • Providing a uniform build system.
  • Providing quality project information.
  • Providing guidelines for best practices development.
  • Allowing transparent migration to new features.

Maven‘s main features.

  • Convention over configuration.
    Maven works over the design software pattern known as Convention over configuration. What means is that Maven takes some beforehand decisions (project structure, path where my source code or resources will be, which compiler I’m going to execute, …) in a software project development. Developers only need to worry about coding the bussiness logic of their  own applications.Maven always recommends following the beforehand convention in their projects. The main reasons are that software projects are easy to develop and new developers find easier to incorporate to a project. Anyhow, Maven allows you to customizing your project to your needings. We don`t need to use convention all the time in our projects.
  • Maven reuse.
    Maven as a software tool doesn`t know a lot. As Maven’s webpage says, Maven knows about reading xml files and interpretate them. Maven knowledge is in its plugins. These plugins  know how to make things work. For example, plugins deal with tasks like compile, generate jar files, test execution or report generation. At the same time, Maven gives us a central repository from where it can be downloaded different libraries, plugins we could need to build our software project. There it is, where Maven reuse can be found. Any software project built with Maven support only need to include this central repository and get what it needs.
  • Project Object Model.
    Maven projects will be defined by a xml file named pom.xml. This file will point the project’s features:
    • Dependency management. Thank to Maven we can deal in a really easy way dependency management. As simple as writing an entry in our pom.xml file, adding JUnit library to our project:
    • Remote repositories.
      As we mentioned previously, Maven has a central repository from where we can select any dependency we wanted to add to our project. Maven will be responsible of getting the libraries that we need to our local enviroment (known as local repository). Not only the central Maven repository exists, but also we can add other repositories to our project (like JBoss‘s repository). We can create a Maven repository to our organization as well.
    • Plugins use.
      There are many Maven plugins we can include in our project. This allows us to add a Jetty plugin and run our aplication on a Jetty server from command line. Moreover, we can compile, test, package, deploy and distribute our project from command line.
    • Build lifecycle.
      Maven‘s build lifecycle has several phases. Besides we can include new goals in our Maven project:
      • Compile: compile our java sources.
      • Test: execute our test.
      • Package: packaging our project in a specific format. (jar, war, ear, …).
      • Install: this will install our project in the local Maven repository.
      • Deploy: deploy our application.

Share this:     

4 comentarios

Publicado por en 24 abril, 2011 en Maven



4 Respuestas a “An introduction to Maven


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s

A %d blogueros les gusta esto: