Apache Maven Tutorials and Dependencies

Ads
 
Tutorials   
Maven dependency for org.http4k - http4k-jsonrpc version 4.13.0.0 is released. Learn to use http4k-jsonrpc version 4.13.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.12.3.1 is released. Learn to use http4k-jsonrpc version 4.12.3.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.12.3.0 is released. Learn to use http4k-jsonrpc version 4.12.3.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.12.2.0 is released. Learn to use http4k-jsonrpc version 4.12.2.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.12.1.0 is released. Learn to use http4k-jsonrpc version 4.12.1.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.12.0.1 is released. Learn to use http4k-jsonrpc version 4.12.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.12.0.0 is released. Learn to use http4k-jsonrpc version 4.12.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.11.0.1 is released. Learn to use http4k-jsonrpc version 4.11.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.11.0.0 is released. Learn to use http4k-jsonrpc version 4.11.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.10.1.0 is released. Learn to use http4k-jsonrpc version 4.10.1.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.10.0.1 is released. Learn to use http4k-jsonrpc version 4.10.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.10.0.0.0 is released. Learn to use http4k-jsonrpc version 4.10.0.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.10.0 is released. Learn to use http4k-jsonrpc version 4.9.10.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.9.0 is released. Learn to use http4k-jsonrpc version 4.9.9.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.8.0 is released. Learn to use http4k-jsonrpc version 4.9.8.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.7.0 is released. Learn to use http4k-jsonrpc version 4.9.7.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.6.0 is released. Learn to use http4k-jsonrpc version 4.9.6.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.5.0 is released. Learn to use http4k-jsonrpc version 4.9.5.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.4.0 is released. Learn to use http4k-jsonrpc version 4.9.4.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.3.1 is released. Learn to use http4k-jsonrpc version 4.9.3.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.3.0 is released. Learn to use http4k-jsonrpc version 4.9.3.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.2.0 is released. Learn to use http4k-jsonrpc version 4.9.2.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.1.0 is released. Learn to use http4k-jsonrpc version 4.9.1.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.0.2 is released. Learn to use http4k-jsonrpc version 4.9.0.2 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.0.1 is released. Learn to use http4k-jsonrpc version 4.9.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.9.0.0 is released. Learn to use http4k-jsonrpc version 4.9.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.8.2.0 is released. Learn to use http4k-jsonrpc version 4.8.2.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.8.1.0 is released. Learn to use http4k-jsonrpc version 4.8.1.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.8.0.0 is released. Learn to use http4k-jsonrpc version 4.8.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.7.1.0 is released. Learn to use http4k-jsonrpc version 4.7.1.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.7.0.2 is released. Learn to use http4k-jsonrpc version 4.7.0.2 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.7.0.1 is released. Learn to use http4k-jsonrpc version 4.7.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.7.0.0 is released. Learn to use http4k-jsonrpc version 4.7.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.6.0.0 is released. Learn to use http4k-jsonrpc version 4.6.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.5.0.1 is released. Learn to use http4k-jsonrpc version 4.5.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.5.0.0 is released. Learn to use http4k-jsonrpc version 4.5.0.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.4.2.0 is released. Learn to use http4k-jsonrpc version 4.4.2.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.4.1.0 is released. Learn to use http4k-jsonrpc version 4.4.1.0 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.4.0.1 is released. Learn to use http4k-jsonrpc version 4.4.0.1 in Maven based Java projects Maven dependency for org.http4k - http4k-jsonrpc version 4.4.0.0 is released. Learn to use http4k-jsonrpc version 4.4.0.0 in Maven based Java projects

Apache Maven Tutorials and Dependencies

Apache Maven is very popular tool among Java developers for building their projects, in this section we are giving many tutorials on Maven and its use in getting the Java library dependencies in the project.

Apache Maven is very popular tool among Java developers for building their projects, in this section we are giving many tutorials on Maven and its use in getting the Java library dependencies in the project.

Apache Maven Tutorials, Articles and Dependencies release

Apache Maven is a very popular tool for managing the Java projects and building the distributable packages of your project. Maven is a complete project management tool for Java developers which allows developers to compile, test, build and release the Java projects in much easier way. In this section we are going to learn Apache Maven with the help of many tutorials and examples. We will also provide you sample projects to get started with the Maven build tool.

Java developers use Maven for managing their Java projects, but Maven is not limited just to Java it can be used with projects written in C#, Ruby, Scala and others. In this section we will mostly discuss the use of Maven in Java projects.

Maven handles the two important aspects of software development: software building process and managing the dependencies in the software project. Maven uses an XML file called pom.xml for defining the project being built and this file is sufficient to describe all the steps of the software project building. In the pom.xml file developers can define all the dependencies, modules, components, software build order and the plug-ins to use during project building. So, it covers all the aspects of modern software building process.

Maven is powerful and feature rich tool, which comes with the comes with the pre-defined configuration for build-order, directories, many plugins and well established process for building complex projects. Maven build tool automatically downloads the libraries and the plug-ins for your project from the remote Maven 2 Central Repository or from other public repositories. The downloaded libraries are stored on the local repository on the developer's machine. Next time it checks the local repository and if libraries are present in the local repository it uses from there in the project. If the libraries are not present it downloads from Maven 2 Central Repository or other specified repository. This process simplifies the dependency management task and developers can concentrate on the application development.

Maven is building the application on the plugin-based architecture and it can be extended to build the C/C++ projects as well. Maven allows you to build and use the plug-ins to simplify the build process, so it can be extended to make custom build solution for your project.

There are other alternative project build including Gradle and sbt, that do not use the XML. The other project build tools including Gradle, sbt, Apache Ivy and others also uses the Maven dependency from remote Maven repositories. Maven is a very popular project management tool which uses the remote repository for downloading project dependencies and eases the project development lifecycle.

History of Maven

Maven tool was created by Jason van Zyl during the development of Apache Turbine project in 2002. Initially, it was a subproject of Apache Turbine project in 2002. Later on, this Maven was voted and accepted as the top level project at Apache Foundation. The first version of Maven v1.0 was released in July 2004, followed by v2.0 release in October 2005. The version v3.0 of the Apache Maven project was released in October 2010. Now Apache Maven is a top level project at Apache foundation and it is being used by millions of developers around the world for building their projects.

Maven Hello World Project

Now we will see how you can create a simple Hello World Project in maven. It is very easy to compile, build and test your Java project using the Maven build tool. Apache maven uses an XML file for managing the project and its dependencies. The configuration file used in Maven is pom.xml file and we will explain you the details of this file.

Creating first Hello World Project is very easy with maven and you can use the maven-archetype-quickstart archetype for creating the example project quickly. First all install the Maven on your computer and go to the terminal and run following command:

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4

Above command will ask you some questions and then create a sample project for you.

Here is the sample of pom.xml file created with the maven archetype generator:


<?xml version="1.0" encoding="UTF-8"?>

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.test</groupId>
  <artifactId>hello-world</artifactId>
  <version>1.0</version>

  <name>hello-world</name>
  <url>https://www.roseindia.net</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

Maven also generates App.java which is Hello World application in Java. Here is code of App.java:


package com.test;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}

Maven follows the pre-defined directory structure and here is the screen shot of the Maven Hello World application:

Maven Hello World Example

Maven command to compile and package the application

Compiling and packaging the project is very easy with the maven and during this process maven downloads the dependency required in your project.

To compile the project you can use following command:

mvn compile

Above command will compile your project as shown below:

Maven compile command

To package your project you can use following command:

mvn package

Here is the output of the command:

Maven Package Command

The mvn package command compiles all the files inside your project and then creates jar file which you can use to run your project.

You can download the Maven Hello World project from here:

Download Maven Hello World example project.

In this tutorial we introduced you with the Apache Maven tool and explained you the steps to use it for compiling your first project.

Ads

Ads