Java Academy Build Tools

42
7/28/2019 Java Academy Build Tools http://slidepdf.com/reader/full/java-academy-build-tools 1/42 Build Tools Java Center of Excellence

Transcript of Java Academy Build Tools

Page 1: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 1/42

Build Tools

Java Center of Excellence

Page 2: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 2/42

2 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Agenda

• Introduction to Build Tools– Why required?

• Apache Ant

– Introduction

– Installation

– Usage

– Hands on

• Apache Maven

– Introduction

– Installation– Usage

– Hands on

• Feedback and Close

Page 3: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 3/42

3 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Introduction

• Imagine yourself working on a large Java project consistingmany .java files. The classes in that are dependent on otherclasses and libraries, which are situated in multipledirectories and the output files must go into multipledirectories too and there are various project build routes fordifferent applications and at the moment all of this is beingdone manually and so many hours are being spentchanging directories compiling individual files and so on...

• Now, imagine if their was a tool that could alleviate thestress and hassle you are experiencing.

• So to alleviate the stress and hassle there are build toolslike

– ANT

– Maven

Page 4: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 4/42

4 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Build Tools - Why required?

• To perform common tasks like:– Compile code by executing common tasks like cleaningprevious build files, copying resources files andgenerating class files

– Generate documentation from source code using JavaDoc

– Perform Unit testing using Use JUnit or TestNG– Generate deployable like .jar file

– Deploy by coping runtime files to a server

Page 5: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 5/42

5 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Apache Ant

• Apache Ant is a software tool for automatingsoftware build processes. It is implemented usingthe Java language, requires the Java platform,and is best suited to building Java projects butcan be used for just about everything.

• Ant uses XML to describe the build process andits dependencies. By default the XML file isnamed build.xml.

• Ant is an Apache project. It is open sourcesoftware, and is released under the ApacheSoftware License.

Page 6: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 6/42

6 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Facts about Ant

• Ant is the build tool used by most Javadevelopment projects. For example, most opensource developers include build.xml files with theirdistribution.

• Ant made it trivial to integrate JUnit & TestNG testswith the build process. This has made it easy forwilling developers to adopt test-drivendevelopment.

• The name ANT is an acronym for "Another NeatTool".

Page 7: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 7/427 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Ant Installation

• Download the binaries fromhttp://ant.apache.org/bindownload.cgi, unzipthem to a suitable directory.

• Append path to ant bin to the PATH environmentvariable.

• Set JAVA_HOME to point to the location of theJDK installation on the machine that the softwareis being installed on.

Page 8: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 8/428 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Ant Basics

• An Ant build file comes in the form of an XML document, allthat is required is a simple text editor to edit the buildfile(s). An editor that provides XML syntax highlighting ispreferable. The Ant installation comes with a JAXP-Compliant XML parser, this means that the installation of anexternal XML parser is not necessary.

• Basic build.xml Example

► <?xml version="1.0"?><project name=“AntApp" default=“Compile" basedir="."> 

<property name="src" value=“src"/> <property name="build" value="build"/>

<target name="init"><mkdir dir="${build}"/>

</target><target name=“Compile" depends="init"> 

<!-- Compile the java code --><javac srcdir="${src}" destdir="${build}"/>

</target></project>

Page 9: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 9/429 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Build.xml (contd.)

• <?xml version="1.0"?>

– Since Ant build files are XML files the document begins with anXML declaration which specifies which version of XML is in use,this is to allow for the possibility of automatic versionrecognition should it become necessary.

• <project name=“AntApp" default=“Compile" basedir="."> 

– The root element of an Ant build file is the project element, ithas three attributes.

► name: The name of the project, it can be any combination of alphanumeric characters that constitute valid XML.

► default: The default target to use when no target is specified, outof these three attributes default is the only required attribute.

► basedir: The base directory from which any relative directoriesused within the Ant build file are referenced from. If this is omittedthe parent directory of the build file will be used.

Page 10: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 10/4210 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Build.xml (contd.)

• <property name="src" value=“src"/> <property name="build" value="build"/>

– The property element allows the declaration of properties which are like user-definable variablesavailable for use within an Ant build file. The name

attribute specifies the name of the property and thevalue attribute specifies the desired value of theproperty. The name and value values are subject tostandard XML constraints.

Page 11: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 11/4211 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Build.xml (contd.)

• <target name="init">

<mkdir dir="${build}"/></target>– The target element is used as a wrapper for a sequences of 

actions. A target has a name, so that it can be referenced fromelsewhere, either externally from the command line, orinternally via the depends keyword, or through a direct call.

The target in the example is called "init" (initiate), it makes adirectory using the mkdir element with the name specified bythe build property defined in three. The target element has anumber of possible attributes, unless otherwise specified,these are optional:

► name: The name of the target is used to reference it fromelsewhere, it is subject to the constraints of XML well formedness.This is the only required attribute for the target element.

► depends: This is a comma separated list of all the targets on whichthis target depends,depends contains the list of the targets thatmust be executed prior to executing this target.

► description: This is a short description of the target.

Page 12: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 12/4212 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Build.xml (contd.)

• <target name="compile" depends="init"><!- - Compile the java code - ->

<javac srcdir="${src}" destdir="${build}"/>

</target>

– The javac element, as used above, is a task , tasks areperformed in the body of a target , in this case, thesource directory is specified by referencing the src property and the destination directory is specified byreferencing the build property. The example above

causes javac to be executed, compiling all the .java filesin the directory specified by the src property and placingthe resultant .class files in the directory specified by thebuild property.

Page 13: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 13/4213 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Executing targets in Ant

• To execute target “init” in the build.xml discussed 

– Navigate to project folder on command prompt

– Execute command “ant init”  

– This will execute the tasks defined under init 

• To execute target “compile”  

– Execute command “ant” as compile is the default targetit will be execute else you can execute “ant compile” aswell

– This will first execute target “init” as “compile” dependson “init” and then execute tasks defined under “compile”  

Page 14: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 14/4214 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Frequently used Ant tasks

• Task java:Javac - Compiles Java source files

• Task java:Java - Launcher for Java applications

• Task java:Javadoc - Generates Javadoc documentationfor a collection of source code

• Task filesystem:Copy - Copies a file or directory to a new

file or directory• Task filesystem:Delete - Deletes a file or directory, or set

of files defined by a fileset

• Task packaging:Jar - Creates a JAR archive

• Task packaging:War - Creates a WAR archive

• Task packaging:Zip - Create a Zip file

• Task filesystem:Mkdir - Creates a given directory

Page 15: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 15/4215 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Exercise

• To get a hands-on on ant we would be buildingan application which will return sum of twointegers passed as arguments to application. Inthe duration of building this application we willlearn how to compile, build and clean this

application using ant.

Page 16: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 16/4216 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create application structure

• Create a folder AntExample.• Create folder src.

• Create package structure com.uhc.ant under src.

Page 17: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 17/4217 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create main class

• Create a main class AntExample.java undersrc/com/uhc/ant folder.

package com.uhc.ant;

public class AntExample {

public static void main(String args[]) {

 AntExampleService aeService = new AntExampleService();

//Prints the sum of two integers passed in the argumentsSystem.out.println("The sum of two integers is :"+aeService.getSum(Integer.parseInt(args[0]),Integer.parseInt(args[1])));

}}

Page 18: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 18/4218 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create service class

• Create a service class AntExampleService.java

under src/com/uhc/ant folder.

package com.uhc.ant;

public class AntExampleService {

/****This method returns the sum of two integers.*/public int getSum(int a, int b) {

return a+b;}}

Page 19: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 19/4219 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Add build.xml

<?xml version="1.0"?><project name="AntExample" default="compile" basedir=".">

<property name="src" value=“src"/> <property name="build" value="build"/>

<target name="init"><mkdir dir="${build}"/>

</target><target name="compile" depends="init"><!-- Compile the java code -->

<javac srcdir="${src}" destdir="${build}"/></target>

<target name="clean" description="Removes previousbuild">

<delete verbose="true"><fileset dir="${build}"/></delete>

</target></project>

• Add project build.xml in base folder

Page 20: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 20/4220 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Init & Compile Execution

• Navigate to project folder on command prompt.• Execute command “ant init”. 

• On successful build execution

– New directory structure build would be created underbase directory

• Now execute command “ant compile”. 

• On successful build execution

– Two classes AntExample.class andAntExampleService.class would be created under

build\com\uhc\ant directory

Page 21: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 21/4221 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Clean Execution

• Execute command “ant clean”. • On successful build execution

– Classes AntExample.class and AntExampleService.classwould be deleted from build\com\uhc\ant directory

• Now execute command “ant”. 

• On successful build execution

– The default target compile will be executed.

Page 22: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 22/4222 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Apache Maven

• Maven is a project management tool whichencompasses

– A project object model (POM)

– A set of standards

– A project lifecycle

– A dependency management system

– Logic for executing plugin goals at defined phases in alifecycle

Page 23: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 23/4223 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Maven Installation

• Download the binaries fromhttp://maven.apache.org/download.html, unzipthem to a suitable directory.

• Add an environment variable M2_HOME and addthe path to maven installation as value.

• Append path to maven bin to the PATHenvironment variable.

• Set JAVA_HOME to point to the location of theJDK installation on the machine that the softwareis being installed on.

• Test the maven installation by running mvn –v oncommand prompt.

Page 24: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 24/4224 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Project Object Model (POM)

• The POM contains four categories of description and

configuration– General project information

► This includes a project’s name, the URL for a project, thesponsoring organization, and a list of developers and contributorsalong with the license for a project.

– Build settings► The behavior of the default Maven build is customized under this

section. The location of source and tests can be changed, newplugins can be added and plugin goals can be attached to lifecycle.

– Build environment► The build environment consists of profiles that can be activated for

use in different environments.

– POM relationships► A project rarely stands alone; it depends on other projects,

inherits POM settings from parent projects, defines its owncoordinates, and may include submodules.

Page 25: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 25/42

25 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Sample pom.xml

<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>com.uhc.maven</groupId><artifactId>MavenExample</artifactId><version>1.0</version><dependencies>

<dependency>

<groupId>org.testng</groupId><artifactId>testng</artifactId><version>5.5</version><classifier>jdk15</classifier><scope>test</scope>

</dependency></dependencies><build>

<plugins><plugin>

<groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.4</version>

</plugin></plugins>

</build></project>

Page 26: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 26/42

26 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

The Build Lifecycle

• A Maven lifecycle consists of a sequence of named phases:validate, compile, package, and install among other. Thereis phase that captures compilation and a phase thatcaptures packaging. There are pre- and post- phases whichcan be used to register goals which must run prior tocompilation, or tasks which must be run after a particular

phase. When you tell Maven to build a project, you aretelling Maven to step through a defined sequence of phasesand execute any goals which may have been registeredwith each phase.

• A build lifecycle is an organized sequence of phases that

exist to give order to a set of goals.

Page 27: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 27/42

27 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Default Lifecycle (default)

• It is a general model of a build process for a softwareapplication. The first phase is validate and the last phase isdeploy

• Maven Lifecycle Phases

Lifecycle Phase Description Commandvalidate Validate the project is

correct and all necessaryinformation is available tocomplete a build

mvn validate

compile Compile the source code of 

the project

mvn compile

Page 28: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 28/42

28 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Maven Lifecycle Phases (contd.)

Lifecycle Phase Description Command

test-compile Compile the test source codeinto the test destinationdirectory

mvn test-compile

test Run tests using a suitable unittesting framework. These testsshould not require the code bepackaged or deployed

mvn test

package Take the compiled code andpackage it in its distributableformat, such as a JAR, WAR,or EAR

mvn package

install Install the package into thelocal repository, for use as adependency in other projectslocally

mvn install

deploy Copies the final package to theremote repository for sharingwith other developers andprojects.

mvn deploy

Page 29: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 29/42

29 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Clean Lifecycle (clean)

• Running mvn clean invokes the clean lifecycle whichconsists of three lifecycle phases:

– pre-clean

– clean

– post-clean

• The interesting phase in the clean lifecycle is the cleanphase. The Clean plugin's clean goal (clean:clean) is boundto the clean phase in the clean lifecycle. The clean:cleangoal deletes the output of a build by deleting the builddirectory. If you haven't customized the location of thebuild directory it will be the ${basedir}/target directory.

Executing the clean phase gives Maven an opportunity toexecute any other goals which may be bound to the pre-clean phase.

Page 30: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 30/42

30 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Build Profiles

• Profiles allow for the ability to customize a particular build

for a particular environment; profiles enable portabilitybetween different build environments.

• Maven allows to define any number of build environments(build profiles) which can override any of the settings in thepom.xml. You could configure your application to read from

your local, development instance of a database in your"development" profile, and you can configure it to readfrom the production database in the "production" profile.

• Profiles can be defined under <profiles> tag in pom.xml orprofiles.xml placed under project’s base directory. Eachprofile is identified by the value given in <id> tag e.g

<id>development</id> denotes development profile.• To execute mvn install under the development profile, you

need to pass the –Pdevelopment argument on thecommand-line.

Page 31: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 31/42

31 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Exercise

• To get a hands-on on maven we would bebuilding an application which will return sum of two integers passed as arguments to application.In the duration of building this application we willlearn how to compile, test, install and clean this

application using maven.

Page 32: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 32/42

32 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create application structure

• Create a folder MavenExample.• Create folders src\main\java, src\test\java,

src\main\resources & src\test\resources underMavenExample.

• Create package structure com.uhc.maven undersrc\main\java and src\test\java.

Page 33: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 33/42

33 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create main class

• Create a main class MavenExample.java under

src/main/java/com/uhc/maven folder.

package com.uhc.maven;

public class MavenExample {

public static void main(String args[]) {

MavenExampleService meService = newMavenExampleService();

//Prints the sum of two integers passed in the argumentsSystem.out.println("The sum of two integers is :"+

meService.getSum(Integer.parseInt(args[0]),Integer.parseInt(args[1])));}

}

Page 34: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 34/42

34 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create service class

• Create a service class MavenExampleService.java undersrc/main/java/com/uhc/maven folder.

package com.uhc.maven;

public class MavenExampleService {

/****This method returns the sum of two integers.*/public int getSum(int a, int b) {

return a+b;}

}

Page 35: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 35/42

35 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Create test class

• Create a test class MavenExampleServiceTest.java under

src/test/java/com/uhc/maven folder.

package com.uhc.maven;import static org.testng.Assert.*;import org.testng.annotations.Test;/*** Unit test for MavenExampleService.

*/public class MavenExampleServiceTest{

@Testpublic void getSumTest() {

MavenExampleService meService = new MavenExampleService();assertEquals(5,meService.getSum(2,3));

}}

Page 36: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 36/42

36 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Add testng.xml

• Add testng.xml under src/test/resources folder.

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Maven Example Test Suite">

<test name="Maven example"><classes><class name="com.uhc.maven.MavenExampleServiceTest" />

</classes></test></suite>

Page 37: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 37/42

37 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

 Add pom.xml

<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>com.uhc.maven</groupId><artifactId>MavenExample</artifactId><version>1.0</version>

<dependencies><dependency>

<groupId>org.testng</groupId><artifactId>testng</artifactId><version>5.5</version><classifier>jdk15</classifier><scope>test</scope>

</dependency></dependencies>

Contd…. 

• Add project pom.xml in base folder

Page 38: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 38/42

38 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

pom.xml (contd.)

<build><plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.4</version><configuration>

<suiteXmlFiles>

<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile></suiteXmlFiles>

</configuration></plugin><plugin>

<groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration>

<source>1.5</source>

<target>1.5</target></configuration>

</plugin>

</plugins></build>

</project>

Page 39: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 39/42

39 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Compile & Clean Execution

• Navigate to project folder on command prompt.

• Execute command “mvn compile”. 

• On successful build execution

– New directory structure target\classes\com\uhc\mavenwould be created under base directory

– Two classes MavenExample.class andMavenExampleService.class would be present under theabove directory

• Now execute command “mvn clean”. 

• On successful build execution– The directory “target” under base directory will be

deleted

Page 40: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 40/42

40 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Test Execution

• Now execute command “mvn test”. 

• On successful build execution

– New directory structures target\classes\com\uhc\maven& target\test-classes\com\uhc\maven would be createdunder base directory

– Two classes MavenExample.class andMavenExampleService.class would be present undertarget\classes\com\uhc\maven andMavenExampleServiceTest.class would be present undertarget\test-classes\com\uhc\maven

– The command prompt will show the number of test run,failures, errors and skipped

Page 41: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 41/42

41 Any use, copying or distribution without written permission from UnitedHealth Group is prohibited.

Install Execution

• Now execute command “mvn install”. 

• On successful build execution

– New directory structures target\classes\com\uhc\maven& target\test-classes\com\uhc\maven would be createdunder base directory

– Two classes MavenExample.class andMavenExampleService.class would be present undertarget\classes\com\uhc\maven andMavenExampleServiceTest.class would be present undertarget\test-classes\com\uhc\maven

– The command prompt will show the number of test run,failures, errors and skipped

Page 42: Java Academy Build Tools

7/28/2019 Java Academy Build Tools

http://slidepdf.com/reader/full/java-academy-build-tools 42/42

Questions