SlideShare a Scribd company logo
1 of 23
Java Build Tools
Sujit Kumar
Zenolocity LLC © 2013-2023
Manual Development Tasks In Eclipse
•
•
•
•
•
•
•
•
•

Clean Code – remove all your class files
Compile Code
Run your application
Run JUnit tests
Package jars
Package wars
Deploy wars to an application server
**** How do u automate all the above? ***
Batch file on windows or Shell Scripts for Unix
and Mac. Not portable.
Available Tools for Automation
•
•
•
•

ANT
Maven
Gradle
All the above (Ant, Maven, Gradle) are
portable options built on top of the JVM.
ANT
• Based on XML.
• Tasks to automate nearly everything that you
can do from a shell script or batch file.
• You can even do procedural flow control using
XML.
Setting up ANT environment variables
on Windows
• set ANT_HOME=C:Userssujitdevappsapacheant-1.8.2
• set PATH=%ANT_HOME%bin;%PATH%
• Verify ANT version by running:
ant –version
• Ant itself needs JAVA_HOME and JDK_HOME to
be set.
Set up environment variables on Unix
• Add the following lines in your ~/.bashrc
• export
ANT_HOME={PATH_TO_PARENT_DIR_OF_ANT
}/apache-ant-1.8.2
• export PATH=$ANT_HOME/bin:$PATH
• Verify ANT version by running:
ant -version
ANT Core tasks Categories – Part 1
• Compile Tasks: javac, depend, jspc, apt
• Execution Tasks: ant, antcall, exec, java,
parallel, sequential
• File Tasks: copy, delete, mkdir, move, replace,
touch, chmod, chgrp, concat,
• Mail Tasks: mail
• SCM Tasks: Cvs, Svn, Clearcase, PVCS.
• Testing Tasks: Junit, JUnitReport.
ANT Core Task Categories – Part 2
• Property Tasks: Property, LoadProperties,
XMLProperty, Dirname, Basename, Condition,
Uptodate, Available, etc.
• Remote Tasks: ftp, scp, telnet, etc.
• Pre-process Tasks: import, include, etc.
• Miscellaneous Tasks: Echo, Fail, Taskdef,
Typedef, Tstamp, etc.
• Archive Tasks: jar, unjar, war, unwar, zip,
unzip, tar, untar, gzip, gunzip.
Flow Control with ANT
• Execute flow control logical tasks like if, for,
foreach, switch, assert, trycatch, etc.
• http://ant-contrib.sourceforge.net/tasks
Maven
• Software project management tool. Manage
project’s build, dependencies & documentation.
• Based on the concept of a project object model
(POM).
• Efficient dependency management by using
repositories of dependent jars.
• Extensible with lot of plugins in java.
• Uses the Convention over configuration design
pattern – minimizes code & decision making
without losing flexibility.
Simple ANT build.xml file
Simple Maven pom.xml file
• <project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook</groupId>
<artifactId>my-project</artifactId>
<version>1.0</version>
• </project>
• See how simple the pom xml file looks like.
• Where Ant had to be explicit about the process, there was
something "built-in" to Maven that just knew where the source
code was and how it should be processed.
• Convention over configuration reduces amount of code and
configuration.
Maven Configuration Files
•
•
•
•
•

JAVA_HOME where JDK is installed.
Add JAVA_HOME/bin to the PATH.
M2_HOME where Maven is installed.
Add M2_HOME/bin to the PATH.
2 locations where a settings.xml file may live:
Global: ${M2_HOME}/conf/settings.xml
Local: ${HOME}/.m2/settings.xml
• If both files exist, contents are merged & local
overrides global.
Maven Repositories
• Local
• Central
• Remote
Local Repository
• Project’s dependent jars are downloaded and
stored in the local repository.
• Default location: {HOME_DIR}/.m2
• Change location of local repository in
{M2_HOME}confsetting.xml, update
localRepository to something else.
Maven Build Life Cycle
• Conventional process for building & distributing
an artifact.
• Defined by a list of build phases. A phase is a
stage in the build process.
• 3 built in build life cycles: default, clean & site.
• Build phases are executed sequentially.
• When a build phase is executed, it will execute
not only that build phase, but also every build
phase prior to the called build phase.
Default Build Life Cycle
•
•
•
•
•
•
•
•
•
•
•
•

validate: validate the project is correct and all necessary information is available.
initialize: initialize build state, eg. Set properties or create directories.
generate-resources: generate resources for inclusion in the package.
process-resources: copy and process the resources into the destination directory.
compile: compile the source code of the project.
test-compile: compile the test source code of the project.
test: test the compiled source code using a suitable unit testing framework. These
tests should not require the code be packaged or deployed
package: take the compiled code and package it in its distributable format, such as
a JAR.
integration-test: process and deploy the package if necessary into an environment
where integration tests can be run
verify: run any checks to verify the package is valid and meets quality criteria
install: install the package into the local repository, for use as a dependency in
other projects locally
deploy: done in an integration or release environment, copies the final package to
the remote repository for sharing with other developers and projects.
Life Cycle Reference
• List in the previous slide not a complete list.
• Full list available here:
• https://maven.apache.org/guides/introductio
n/introduction-to-thelifecycle.html#Lifecycle_Reference
Maven Goals & Phases
• Goals are executed in phases which helps determine the order
goals get executed in.
• Compile phase goals will always be executed before the Test phase
goals which will always be executed before the Package phase goals
and so on.
• When you create a plugin execution in your Maven build file and
you only specify the goal then it will bind that goal to a given
default phase. For example, the jaxb:xjc goal binds by default to the
generate-resources phase. However, when you specify the
execution you can also explicitly specify the phase for that goal as
well.
• If you specify a goal when you execute Maven then it will still run all
phases up to the phase for that goal. In other words, if you specify
the jar goal it will run all phases up to the package phase (and all
goals in those phases), and then it will run the jar goal.
Differences between ANT and Maven –
part 1
• 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.
Informal conventions have emerged over time, but
they haven't been codified into the product.
• Ant 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.
• Ant doesn't have a lifecycle, you have to define goals
and goal dependencies. You have to attach a sequence
of tasks to each goal manually.
Differences between ANT and Maven –
part 2
• Maven has conventions, it knows where your source code
is because you followed the convention. It puts the byte
code in target/classes, and it created a JAR file in target.
• Maven is declarative. All you had to do was create a
pom.xml file and put your source in the default directory.
Maven took care of the rest.
• Maven has a lifecycle, which you invoked when you
executed “mvn” install. This command tells Maven to
execute a sequence of steps until it reached the lifecycle.
As a side-effect of this journey through the lifecycle, Maven
executed a number of default plugin goals which did things
like compile and create a JAR.
Differences between ANT and Mavenpart 3
• Maven has intelligence about common
project tasks. To run tests, simple execute mvn
test, as long as the files are in the default
location. In Ant, you would first have to
specify the location of the JUnit JAR file, then
create a classpath that includes the JUnit JAR,
then tell Ant where it should look for test
source code, write a goal that compiles the
test source and then finally execute the unit
tests with JUnit.
Comparison with Gradle
• http://xpanxionsoftware.wordpress.com/2012
/05/11/ant-maven-and-gradle-a-side-by-sidecomparison/

More Related Content

What's hot

Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonEclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonVladLica
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldDmitry Bakaleinik
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and AntDavid Noble
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1MD Sayem Ahmed
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to MavenVadym Lotar
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 featuresAngel Ruiz
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovskyphp-user-group-minsk
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
Gerência de Configuração com Maven
Gerência de Configuração com MavenGerência de Configuração com Maven
Gerência de Configuração com Mavenelliando dias
 
Jenkins Meetup Pune
Jenkins Meetup PuneJenkins Meetup Pune
Jenkins Meetup PuneUmesh Kumhar
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)Johan Mynhardt
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2andyhot
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal infoSynapseindiappsdevelopment
 
Drupal & Continous Integration - SF State Study Case
Drupal & Continous Integration - SF State Study CaseDrupal & Continous Integration - SF State Study Case
Drupal & Continous Integration - SF State Study CaseEmanuele Quinto
 
Introduce fuego
Introduce fuegoIntroduce fuego
Introduce fuegos60030
 

What's hot (20)

Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonEclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Maven
MavenMaven
Maven
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovsky
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Gerência de Configuração com Maven
Gerência de Configuração com MavenGerência de Configuração com Maven
Gerência de Configuração com Maven
 
Jenkins Meetup Pune
Jenkins Meetup PuneJenkins Meetup Pune
Jenkins Meetup Pune
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
Using Maven2
Using Maven2Using Maven2
Using Maven2
 
Drupal & Continous Integration - SF State Study Case
Drupal & Continous Integration - SF State Study CaseDrupal & Continous Integration - SF State Study Case
Drupal & Continous Integration - SF State Study Case
 
Introduce fuego
Introduce fuegoIntroduce fuego
Introduce fuego
 

Viewers also liked

Java Build Tools
Java Build ToolsJava Build Tools
Java Build Tools­Avishek A
 
Java input output package
Java input output packageJava input output package
Java input output packageSujit Kumar
 
Unit testing principles
Unit testing principlesUnit testing principles
Unit testing principlesSujit Kumar
 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with javaSujit Kumar
 

Viewers also liked (6)

Java Build Tools
Java Build ToolsJava Build Tools
Java Build Tools
 
Java input output package
Java input output packageJava input output package
Java input output package
 
Jdbc
JdbcJdbc
Jdbc
 
Unit testing principles
Unit testing principlesUnit testing principles
Unit testing principles
 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
 
Java file paths
Java file pathsJava file paths
Java file paths
 

Similar to Java build tools

Similar to Java build tools (20)

Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOps
 
Build Tools & Maven
Build Tools & MavenBuild Tools & Maven
Build Tools & Maven
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Maven
MavenMaven
Maven
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
Devops
DevopsDevops
Devops
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
maven
mavenmaven
maven
 

More from Sujit Kumar

SFDC Database Basics
SFDC Database BasicsSFDC Database Basics
SFDC Database BasicsSujit Kumar
 
SFDC Database Security
SFDC Database SecuritySFDC Database Security
SFDC Database SecuritySujit Kumar
 
SFDC Social Applications
SFDC Social ApplicationsSFDC Social Applications
SFDC Social ApplicationsSujit Kumar
 
SFDC Other Platform Features
SFDC Other Platform FeaturesSFDC Other Platform Features
SFDC Other Platform FeaturesSujit Kumar
 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound IntegrationsSujit Kumar
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound IntegrationsSujit Kumar
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSujit Kumar
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to VisualforceSujit Kumar
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC DeploymentsSujit Kumar
 
SFDC Data Loader
SFDC Data LoaderSFDC Data Loader
SFDC Data LoaderSujit Kumar
 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex Sujit Kumar
 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to ApexSujit Kumar
 
SFDC Database Additional Features
SFDC Database Additional FeaturesSFDC Database Additional Features
SFDC Database Additional FeaturesSujit Kumar
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForceSujit Kumar
 
More about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolMore about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolSujit Kumar
 
Hibernate First and Second level caches
Hibernate First and Second level cachesHibernate First and Second level caches
Hibernate First and Second level cachesSujit Kumar
 
Java equals hashCode Contract
Java equals hashCode ContractJava equals hashCode Contract
Java equals hashCode ContractSujit Kumar
 
Java Comparable and Comparator
Java Comparable and ComparatorJava Comparable and Comparator
Java Comparable and ComparatorSujit Kumar
 
Java Web services
Java Web servicesJava Web services
Java Web servicesSujit Kumar
 

More from Sujit Kumar (20)

SFDC Database Basics
SFDC Database BasicsSFDC Database Basics
SFDC Database Basics
 
SFDC Database Security
SFDC Database SecuritySFDC Database Security
SFDC Database Security
 
SFDC Social Applications
SFDC Social ApplicationsSFDC Social Applications
SFDC Social Applications
 
SFDC Other Platform Features
SFDC Other Platform FeaturesSFDC Other Platform Features
SFDC Other Platform Features
 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
 
SFDC Deployments
SFDC DeploymentsSFDC Deployments
SFDC Deployments
 
SFDC Batch Apex
SFDC Batch ApexSFDC Batch Apex
SFDC Batch Apex
 
SFDC Data Loader
SFDC Data LoaderSFDC Data Loader
SFDC Data Loader
 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex
 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to Apex
 
SFDC Database Additional Features
SFDC Database Additional FeaturesSFDC Database Additional Features
SFDC Database Additional Features
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
 
More about java strings - Immutability and String Pool
More about java strings - Immutability and String PoolMore about java strings - Immutability and String Pool
More about java strings - Immutability and String Pool
 
Hibernate First and Second level caches
Hibernate First and Second level cachesHibernate First and Second level caches
Hibernate First and Second level caches
 
Java equals hashCode Contract
Java equals hashCode ContractJava equals hashCode Contract
Java equals hashCode Contract
 
Java Comparable and Comparator
Java Comparable and ComparatorJava Comparable and Comparator
Java Comparable and Comparator
 
Java Web services
Java Web servicesJava Web services
Java Web services
 

Recently uploaded

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 

Recently uploaded (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

Java build tools

  • 1. Java Build Tools Sujit Kumar Zenolocity LLC © 2013-2023
  • 2. Manual Development Tasks In Eclipse • • • • • • • • • Clean Code – remove all your class files Compile Code Run your application Run JUnit tests Package jars Package wars Deploy wars to an application server **** How do u automate all the above? *** Batch file on windows or Shell Scripts for Unix and Mac. Not portable.
  • 3. Available Tools for Automation • • • • ANT Maven Gradle All the above (Ant, Maven, Gradle) are portable options built on top of the JVM.
  • 4. ANT • Based on XML. • Tasks to automate nearly everything that you can do from a shell script or batch file. • You can even do procedural flow control using XML.
  • 5. Setting up ANT environment variables on Windows • set ANT_HOME=C:Userssujitdevappsapacheant-1.8.2 • set PATH=%ANT_HOME%bin;%PATH% • Verify ANT version by running: ant –version • Ant itself needs JAVA_HOME and JDK_HOME to be set.
  • 6. Set up environment variables on Unix • Add the following lines in your ~/.bashrc • export ANT_HOME={PATH_TO_PARENT_DIR_OF_ANT }/apache-ant-1.8.2 • export PATH=$ANT_HOME/bin:$PATH • Verify ANT version by running: ant -version
  • 7. ANT Core tasks Categories – Part 1 • Compile Tasks: javac, depend, jspc, apt • Execution Tasks: ant, antcall, exec, java, parallel, sequential • File Tasks: copy, delete, mkdir, move, replace, touch, chmod, chgrp, concat, • Mail Tasks: mail • SCM Tasks: Cvs, Svn, Clearcase, PVCS. • Testing Tasks: Junit, JUnitReport.
  • 8. ANT Core Task Categories – Part 2 • Property Tasks: Property, LoadProperties, XMLProperty, Dirname, Basename, Condition, Uptodate, Available, etc. • Remote Tasks: ftp, scp, telnet, etc. • Pre-process Tasks: import, include, etc. • Miscellaneous Tasks: Echo, Fail, Taskdef, Typedef, Tstamp, etc. • Archive Tasks: jar, unjar, war, unwar, zip, unzip, tar, untar, gzip, gunzip.
  • 9. Flow Control with ANT • Execute flow control logical tasks like if, for, foreach, switch, assert, trycatch, etc. • http://ant-contrib.sourceforge.net/tasks
  • 10. Maven • Software project management tool. Manage project’s build, dependencies & documentation. • Based on the concept of a project object model (POM). • Efficient dependency management by using repositories of dependent jars. • Extensible with lot of plugins in java. • Uses the Convention over configuration design pattern – minimizes code & decision making without losing flexibility.
  • 12. Simple Maven pom.xml file • <project> <modelVersion>4.0.0</modelVersion> <groupId>org.sonatype.mavenbook</groupId> <artifactId>my-project</artifactId> <version>1.0</version> • </project> • See how simple the pom xml file looks like. • Where Ant had to be explicit about the process, there was something "built-in" to Maven that just knew where the source code was and how it should be processed. • Convention over configuration reduces amount of code and configuration.
  • 13. Maven Configuration Files • • • • • JAVA_HOME where JDK is installed. Add JAVA_HOME/bin to the PATH. M2_HOME where Maven is installed. Add M2_HOME/bin to the PATH. 2 locations where a settings.xml file may live: Global: ${M2_HOME}/conf/settings.xml Local: ${HOME}/.m2/settings.xml • If both files exist, contents are merged & local overrides global.
  • 14. Maven Repositories • Local • Central • Remote
  • 15. Local Repository • Project’s dependent jars are downloaded and stored in the local repository. • Default location: {HOME_DIR}/.m2 • Change location of local repository in {M2_HOME}confsetting.xml, update localRepository to something else.
  • 16. Maven Build Life Cycle • Conventional process for building & distributing an artifact. • Defined by a list of build phases. A phase is a stage in the build process. • 3 built in build life cycles: default, clean & site. • Build phases are executed sequentially. • When a build phase is executed, it will execute not only that build phase, but also every build phase prior to the called build phase.
  • 17. Default Build Life Cycle • • • • • • • • • • • • validate: validate the project is correct and all necessary information is available. initialize: initialize build state, eg. Set properties or create directories. generate-resources: generate resources for inclusion in the package. process-resources: copy and process the resources into the destination directory. compile: compile the source code of the project. test-compile: compile the test source code of the project. test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed package: take the compiled code and package it in its distributable format, such as a JAR. integration-test: process and deploy the package if necessary into an environment where integration tests can be run verify: run any checks to verify the package is valid and meets quality criteria install: install the package into the local repository, for use as a dependency in other projects locally deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
  • 18. Life Cycle Reference • List in the previous slide not a complete list. • Full list available here: • https://maven.apache.org/guides/introductio n/introduction-to-thelifecycle.html#Lifecycle_Reference
  • 19. Maven Goals & Phases • Goals are executed in phases which helps determine the order goals get executed in. • Compile phase goals will always be executed before the Test phase goals which will always be executed before the Package phase goals and so on. • When you create a plugin execution in your Maven build file and you only specify the goal then it will bind that goal to a given default phase. For example, the jaxb:xjc goal binds by default to the generate-resources phase. However, when you specify the execution you can also explicitly specify the phase for that goal as well. • If you specify a goal when you execute Maven then it will still run all phases up to the phase for that goal. In other words, if you specify the jar goal it will run all phases up to the package phase (and all goals in those phases), and then it will run the jar goal.
  • 20. Differences between ANT and Maven – part 1 • 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. Informal conventions have emerged over time, but they haven't been codified into the product. • Ant 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. • Ant doesn't have a lifecycle, you have to define goals and goal dependencies. You have to attach a sequence of tasks to each goal manually.
  • 21. Differences between ANT and Maven – part 2 • Maven has conventions, it knows where your source code is because you followed the convention. It puts the byte code in target/classes, and it created a JAR file in target. • Maven is declarative. All you had to do was create a pom.xml file and put your source in the default directory. Maven took care of the rest. • Maven has a lifecycle, which you invoked when you executed “mvn” install. This command tells Maven to execute a sequence of steps until it reached the lifecycle. As a side-effect of this journey through the lifecycle, Maven executed a number of default plugin goals which did things like compile and create a JAR.
  • 22. Differences between ANT and Mavenpart 3 • Maven has intelligence about common project tasks. To run tests, simple execute mvn test, as long as the files are in the default location. In Ant, you would first have to specify the location of the JUnit JAR file, then create a classpath that includes the JUnit JAR, then tell Ant where it should look for test source code, write a goal that compiles the test source and then finally execute the unit tests with JUnit.
  • 23. Comparison with Gradle • http://xpanxionsoftware.wordpress.com/2012 /05/11/ant-maven-and-gradle-a-side-by-sidecomparison/