maven and ant

31
Java Build tools : Ant and Maven Ant was the first among “modern” build tools. It was released in 2000 and in a short period of time became the most popular build tool for Java projects. It is very easy to learn thus allowing anyone to start using it without any special preparation. It is based on procedural programming idea. Maven was released in 2004. Its goal was to improve upon some of the problems developers were facing when using Ant. © Sun Technologies Inc. 1

Upload: sun-technlogies

Post on 06-Apr-2017

42 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Maven and ANT

© Sun Technologies Inc.

1

Java Build tools : Ant and Maven

Ant was the first among “modern” build tools.

It was released in 2000 and in a short period of time became the most popular build tool for Java projects.

It is very easy to learn thus allowing anyone to start using it without any special

preparation.

It is based on procedural programming idea.

Maven was released in 2004. Its goal was to improve upon some of the problems developers were facing when using Ant.

Page 2: Maven and ANT

2© Sun Technologies Inc.

Apache Ant features Ant doesn’t have formal conventions like a common project directory structure or

default behavior. You have to tell Ant exactly where to find the source and where to put the output. Ant is procedural. You have to tell Ant exactly what to do and when to do it.

Page 3: Maven and ANT

3© Sun Technologies Inc.

Getting started with Ant Download and unzip the latest version of ANT. You should have installed Java and set up path of JAVA_HOME. Set PATH environment variable by appending path of ANT. Build a basic ANT script and run from command prompt.

Page 4: Maven and ANT

4© Sun Technologies Inc.

Running and checking whether Ant is installed in the system .

Page 5: Maven and ANT

5© Sun Technologies Inc.

Writing build.xml file in Notepad

Page 6: Maven and ANT

6© Sun Technologies Inc.

Running build.xml file in command prompt

Page 7: Maven and ANT

7© Sun Technologies Inc.

Running hello.xml file

Page 8: Maven and ANT

8© Sun Technologies Inc.

Executing hello.xml in command prompt

Page 9: Maven and ANT

9© Sun Technologies Inc.

Executing hello.xml in command prompt

Page 10: Maven and ANT

10© Sun Technologies Inc.

Writing Second target in hello.xml

Page 11: Maven and ANT

11© Sun Technologies Inc.

Executing Second target of hello.xml in command prompt

Page 12: Maven and ANT

12© Sun Technologies Inc.

Executing build.xml in eclipse

Page 13: Maven and ANT

13© Sun Technologies Inc.

Executing build.xml in eclipse

Page 14: Maven and ANT

14© Sun Technologies Inc.

Executing run target

Page 15: Maven and ANT

15© Sun Technologies Inc.

Executing run target in eclipse

Page 16: Maven and ANT

16© Sun Technologies Inc.

Executing second run target in eclipse

Page 17: Maven and ANT

17© Sun Technologies Inc.

Sample Ant build.xml

Page 18: Maven and ANT

18© Sun Technologies Inc.

Apache Maven

Apache Maven is a open source build testing tool. It will check the compilation issue in entire framework based on the concept of a project object model (POM), Maven can manage project's build, reporting and documentation.

Page 19: Maven and ANT

19© Sun Technologies Inc.

Apache Maven features Maven has conventions. It knows where your source code is because you followed the convention. Maven’s Compiler plugin put the bytecode in target/classes, and it produces a JAR file in target.

Maven is declarative. All you need to do is create a pom.xml file and put your source in the default directory. Maven will take care of the rest.

Page 20: Maven and ANT

20© Sun Technologies Inc.

Apache Maven Installation Download latest version of maven and unzip the folder. Copy the bin path. Go to environment variables find path variable and edit and paste the bin path. Create a new variable as Maven_Home and paste the path of Maven. And the Java_Home should contain path of the java. Go to command prompt and check whether maven is installed or not by typing mvn –version.

Page 21: Maven and ANT

21© Sun Technologies Inc.

Apache Maven Installation

Page 22: Maven and ANT

22© Sun Technologies Inc.

Downloading jars from command prompt

Page 23: Maven and ANT

23© Sun Technologies Inc.

Apache Maven Installation

First we need to add all the dependencies to pom.xml file.Then run,

mvn compile is a command to get dependencies jar from internetIt will download Jars from internet based on pom.xml file.

mvn installCommand for executing test script from command prompt.

Page 24: Maven and ANT

24© Sun Technologies Inc.

Apache Maven with eclipse Install maven plugin in eclipseHelp -> install new software install the plugin m2e - Maven Integration for Eclipse

Install java

Page 25: Maven and ANT

25© Sun Technologies Inc.

Apache Maven with eclipse

Page 26: Maven and ANT

26© Sun Technologies Inc.

Apache Maven with eclipse

Page 27: Maven and ANT

27© Sun Technologies Inc.

Apache Maven with eclipse

Page 28: Maven and ANT

28© Sun Technologies Inc.

Apache Maven with eclipse

Page 29: Maven and ANT

29© Sun Technologies Inc.

Apache Ant VS Maven

ANT,doesn't have formal conventions like a common project directory structure,

you have to tell Ant exactly where to find the source and where to put the output.

is procedural, you have to tell Ant exactly what to do and when to do it. You had to tell it to compile, then copy, then compress.

doesn't have a lifecycle, you had to define goals and goal dependencies. You had to attach a sequence of tasks to each goal/target manually.

Page 30: Maven and ANT

30© Sun Technologies Inc.

Apache Ant VS Maven

Maven, has conventions, it already knew where your source code was because you followed

the convention. It put the bytecode in target/classes, and it produced a JAR file in target.

is declarative. All you need to do is create a pom.xml file and put your source in the default directory. Maven will take care of the rest.

Page 31: Maven and ANT

31© Sun Technologies Inc.

Thank you