Pitch your project

Random text






Blogs

0    
By admin Category Uncategorized, Posted December 23rd, 2015
Introduction to Maven

We came across Maven when we were deploying the HHS site on a server. The existing file system was being very difficult to deploy because of the file arrangement and getting the dependencies.

Apache Maven is a software project management and comprehension tool that can manage a project’s build, reporting and documentation from a central piece of information. Maven addresses two aspects of building software: First, it describes how software is built, and second, it describes its dependencies.

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:

  • 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 projects are configured using a Project Object Model, which is stored in a pom.xml which defines a unique identifier for the project (coordinates) and its dependency on the JUnit framework. Maven’s dependency-handling mechanism is organized around a coordinate system identifying individual artifacts such as software libraries or modules. For example, a project that needs the JSON library simply has to declare JSON’s project coordinates in its POM. Maven will automatically download the dependency and the dependencies that JSON itself needs (called transitive dependencies) and store them in the user’s local repository.

A simple example of the structure of a POM file is:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4\_0\_0.xsd">

    <modelversion>4.0.0</modelversion>
        <groupid>org.baraza</groupid>
        <artifactid>barazaForms</artifactid>
        <packaging>war</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>barazaForms Maven Webapp</name>
        <url>http://maven.apache.org</url>

        <dependencies>

            <!-- servlet -->
            <dependency>
                <groupid>javax.servlet</groupid>
                <artifactid>javax.servlet-api</artifactid>
                <version>3.1.0</version>
            </dependency>

            <!-- JSON -->
            <dependency>
                <groupid>com.googlecode.json-simple</groupid>
                <artifactid>json-simple</artifactid>
                <version>1.1</version>
            </dependency>

        </dependencies>

        <build>
            <finalname>barazaforms</finalname>
        </build>

</project>

Maven has various directories such as project home, src/main/java, etc. which have different purposes. The command mvn package compiles all the Java files, run any tests, and package the deliverable code and resources into a .war file.

Any more information on the installation or running or even FAQs is available on https://maven.apache.org/.

Posted by Evelyne Wahome

Leave a Reply

Your email address will not be published. Required fields are marked *