SlideShare a Scribd company logo
Maven 2.0Maven 2.0
IntroductionIntroduction
Before ANTBefore ANT
 Earlier tool used for build was "make"Earlier tool used for build was "make"
 The syntax used to be very crypticThe syntax used to be very cryptic
 Maintenance of many make filesMaintenance of many make files
ANTANT
 ANT is cross platformANT is cross platform
 ANT is java basedANT is java based
 ANT replaces the make file's difficultANT replaces the make file's difficult
syntax with more standardized XMLsyntax with more standardized XML
Tasks of a configurationTasks of a configuration
and build managerand build manager
 Copy, CleanCopy, Clean
 Compile, JarCompile, Jar
 Jar class filesJar class files
 Generate the java docGenerate the java doc
 Test and DeployTest and Deploy
Disadvantages of ANTDisadvantages of ANT
 Generally you have a template with whichGenerally you have a template with which
you begin with for a new projectyou begin with for a new project
 Ant does not provide convenient ways ofAnt does not provide convenient ways of
reuse of code. Most of the targets or buildreuse of code. Most of the targets or build
scripts look similar, but one has to resortscripts look similar, but one has to resort
to copy paste to reuse the same code.to copy paste to reuse the same code.
 Creating custom tasks is a workaround,Creating custom tasks is a workaround,
but then it becomes an extra activity tobut then it becomes an extra activity to
write and maintain custom tags in ANTwrite and maintain custom tags in ANT
Disadvantages of ANTDisadvantages of ANT
 The size of the script grows as the numberThe size of the script grows as the number
of tasks executed increase and one has toof tasks executed increase and one has to
write all this and maintain these complexwrite all this and maintain these complex
ANT scriptsANT scripts
 Logic and looping structures are notLogic and looping structures are not
supported and one has to use custom buildsupported and one has to use custom build
tasks for the same. These custom taskstasks for the same. These custom tasks
might not be reusable across projects. If youmight not be reusable across projects. If you
intend to do that, then one will have to put inintend to do that, then one will have to put in
lot of effort to write such tasks. Generallylot of effort to write such tasks. Generally
you end up with numerous and redundantyou end up with numerous and redundant
task in each project.task in each project.
MAVENMAVEN
Maven is a high-level, projectMaven is a high-level, project
management, build and deploymentmanagement, build and deployment
tool from the Apache project that addstool from the Apache project that adds
a layer of abstraction above Ant.a layer of abstraction above Ant.
Tasks Maven can doTasks Maven can do
 Compile your code.Compile your code.
 Create Java doc documentation.Create Java doc documentation.
 Run unit tests.Run unit tests.
 Run source code metrics and analysis.Run source code metrics and analysis.
 Create a report detailing violations of yourCreate a report detailing violations of your
team's coding standards.team's coding standards.
 Create a report of the most recent CVSCreate a report of the most recent CVS
commits.commits.
 Create a report of the CVS activity, pivoted byCreate a report of the CVS activity, pivoted by
file and developer.file and developer.
Maven AdvantagesMaven Advantages
 Supports common build related tasksSupports common build related tasks
 Most of the generic tasks have already beenMost of the generic tasks have already been
shipped with maven.shipped with maven.
 Most of the task have to be written manuallyMost of the task have to be written manually
in case of ant. Maven is standardized. Itsin case of ant. Maven is standardized. Its
basically based on POM. POM is the waybasically based on POM. POM is the way
one indicates the directory structure toone indicates the directory structure to
maven. Once this is done one can executemaven. Once this is done one can execute
most of the inbuilt maven goals (equivalentmost of the inbuilt maven goals (equivalent
of ant targets).of ant targets).
Maven AdvantagesMaven Advantages
 Tasks like Compile, Copy, Clean, Jar, JavaTasks like Compile, Copy, Clean, Jar, Java
doc ,Test, Deploy can be executed usingdoc ,Test, Deploy can be executed using
maven without writing even a single line ofmaven without writing even a single line of
script.script.
 Produces lot of technical information to trackProduces lot of technical information to track
the state of the projectthe state of the project
 All the ant tasks are available from insideAll the ant tasks are available from inside
your Maven projectyour Maven project
Maven GoalsMaven Goals
 mvn cleanmvn clean
 mvn compilemvn compile
 mvn packagemvn package
 mvn testmvn test
 mvn site:generatemvn site:generate
 mvn eclipse:eclipsemvn eclipse:eclipse
POMPOM
Its a XML file. Describes project directory structure,Its a XML file. Describes project directory structure,
project dependencies like jar files. Its a kind ofproject dependencies like jar files. Its a kind of
metadata. Once the project is described using POM,metadata. Once the project is described using POM,
any of the maven tasks can be invoked. Theany of the maven tasks can be invoked. The
pom.xml file is the core of a project's configuration inpom.xml file is the core of a project's configuration in
Maven. It is a single configuration file that containsMaven. It is a single configuration file that contains
the majority of information required to build a projectthe majority of information required to build a project
in just the way you want. The POM is huge and canin just the way you want. The POM is huge and can
be daunting in its complexity, but it is not necessarybe daunting in its complexity, but it is not necessary
to understand all of the intricacies just yet to use itto understand all of the intricacies just yet to use it
effectively.effectively.
POMPOM
<project xmlns="http://maven.apache.org/POM/4.0.0"<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-
v4_0_0.xsd">v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion><modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId><groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId><artifactId>my-app</artifactId>
<packaging>jar</packaging><packaging>jar</packaging>
<version>1.0-SNAPSHOT</version><version>1.0-SNAPSHOT</version>
<name>my-app</name><name>my-app</name>
<url>http://maven.apache.org</url><url>http://maven.apache.org</url>
<dependencies><dependencies>
<dependency><dependency>
<groupId>junit</groupId><groupId>junit</groupId>
<artifactId>junit</artifactId><artifactId>junit</artifactId>
<version>3.8.1</version><version>3.8.1</version>
<scope>test</scope><scope>test</scope>
</dependency></dependency>
<dependency><dependency>
<groupId>org.apache.maven.plugins</groupId><groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId><artifactId>maven-jar-plugin</artifactId>
<version>2.2</version><version>2.2</version>
<scope>test</scope><scope>test</scope>
</dependency></dependency>
</dependencies></dependencies>
</project></project>
Standard Directory StructureStandard Directory Structure
By using the standard conventions theBy using the standard conventions the
POM becomes very small and youPOM becomes very small and you
haven't had to tell Maven explicitlyhaven't had to tell Maven explicitly
where any of your sources are orwhere any of your sources are or
where the output should go. Bywhere the output should go. By
following the standard Mavenfollowing the standard Maven
conventions you can get a lot doneconventions you can get a lot done
with very little effortwith very little effort
Standard Directory StructureStandard Directory Structure
my-appmy-app
|-- pom.xml|-- pom.xml
`-- src`-- src
|-- main|-- main
| `-- java| `-- java
| `-- com| `-- com
| `-- mycompany| `-- mycompany
| `-- app| `-- app
| `-- App.java| `-- App.java
`-- test`-- test
`-- java`-- java
`-- com`-- com
`-- mycompany`-- mycompany
`-- app`-- app
`-- AppTest.java`-- AppTest.java
Unit Testing SupportUnit Testing Support
Maven makes it easy for theMaven makes it easy for the
programmer to build his test cases andprogrammer to build his test cases and
execute them. The support for testexecute them. The support for test
cases is build into the maven and onlycases is build into the maven and only
thing programmer has to do is put thething programmer has to do is put the
test classes in the appropriate directorytest classes in the appropriate directory
Protecting Your ResourcesProtecting Your Resources
Class files are usually loaded from the classpath.Class files are usually loaded from the classpath.
Non-class files (resources) can be loaded from theNon-class files (resources) can be loaded from the
classpath as well, using the various getResourceclasspath as well, using the various getResource
methods. If you want to keep these resources frommethods. If you want to keep these resources from
getting wiped out every time you invoke the cleangetting wiped out every time you invoke the clean
goal, you need to store resources outside of thegoal, you need to store resources outside of the
classes directory and copy them into the classesclasses directory and copy them into the classes
directory as part of the build process. Maven has adirectory as part of the build process. Maven has a
goal for this purpose called jar-resources. It doesn'tgoal for this purpose called jar-resources. It doesn't
jar anything, it just copies resources to thejar anything, it just copies resources to the
target/classes directory. Maven automatically callstarget/classes directory. Maven automatically calls
the jar-resources goal when you run the jar goal.the jar-resources goal when you run the jar goal.
Protecting Your ResourcesProtecting Your Resources
First, you need to tell Maven where your resource files are:First, you need to tell Maven where your resource files are:
Add the resources element, as shown below, to POM.xml:Add the resources element, as shown below, to POM.xml:
......
</unitTest></unitTest>
<resources><resources>
<resource><resource>
<directory><directory>
${basedir}/src/conf${basedir}/src/conf
</directory></directory>
</resource></resource>
</resources></resources>
</build></build>
......
Place a resource file, say box.properties, in <project_home>/src/conf.Place a resource file, say box.properties, in <project_home>/src/conf.
Run the jar goal, which indirectly runs the jar-resources goal: mvn jarRun the jar goal, which indirectly runs the jar-resources goal: mvn jar
Look in the target/classes folder. You should see that Maven copied box.propertiesLook in the target/classes folder. You should see that Maven copied box.properties
from src/conf to target/classes.from src/conf to target/classes.
DependenciesDependencies
The dependencies section of the pom.xmlThe dependencies section of the pom.xml
lists all of the external dependencies thatlists all of the external dependencies that
our project needs in order to build (whetherour project needs in order to build (whether
it needs that dependency at compile time,it needs that dependency at compile time,
test time, run time, or whatever)test time, run time, or whatever)
scope : compile , test , and runtimescope : compile , test , and runtime
DependenciesDependencies
......
<dependencies><dependencies>
<dependency><dependency>
<groupId>junit</groupId><groupId>junit</groupId>
<artifactId>junit</artifactId><artifactId>junit</artifactId>
<version>3.8.1</version><version>3.8.1</version>
<scope>test</scope><scope>test</scope>
</dependency></dependency>
</dependencies></dependencies>
......
Repository FeatureRepository Feature
 Another interesting feature of Maven is its use of a central repositoryAnother interesting feature of Maven is its use of a central repository
to access the .jars needed to build your project . You list what .jarsto access the .jars needed to build your project . You list what .jars
and versions you need, and Maven is intelligent enough to go andand versions you need, and Maven is intelligent enough to go and
download them for you. When you run Maven for the first time, ordownload them for you. When you run Maven for the first time, or
attain a new goal, you will see console output detailing repositoryattain a new goal, you will see console output detailing repository
access to download any required .jars. This is a great feature thataccess to download any required .jars. This is a great feature that
not only makes Maven easier to use and set up, but also saves younot only makes Maven easier to use and set up, but also saves you
a lot of time and the headaches of keeping your own collection ofa lot of time and the headaches of keeping your own collection of
dependencies up to date in a local directory or in your source-codedependencies up to date in a local directory or in your source-code
control system.control system.
 Maven checks the local repository and download the jars, which areMaven checks the local repository and download the jars, which are
not available in the local repositorynot available in the local repository..
 (~/.m2/repository is the default location(~/.m2/repository is the default location
e.g C:Documents and Settingsdarshan.vartak.m2e.g C:Documents and Settingsdarshan.vartak.m2
InternationalizationInternationalization
<project xmlns="http://maven.apache.org/POM/4.0.0"<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">http://maven.apache.org/xsd/maven-4.0.0.xsd">
......
<build><build>
<plugins><plugins>
<plugin><plugin>
<groupId>org.apache.maven.plugins</groupId><groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId><artifactId>maven-site-plugin</artifactId>
<configuration><configuration>
<locales>en,fr</locales><locales>en,fr</locales>
</configuration></configuration>
</plugin></plugin>
</plugins></plugins>
......
Maven TermsMaven Terms
Project Object
Model
(POM)
An XML file that declaratively describes a project
• Basically, the POM is project meta-data. Meta-data includes build,
dependency, and general project management information. This
information is used by goals.
Goal
An executable function that acts upon a project
• Goals are written in Jelly Script. They can be project-specific or
reusable across projects. In either case, they act upon your
project. In OOP terms, think of your project and its meta-data as
an object and goals as the methods that act upon that project.
Jelly Script
Executable XML
• Jelly is an XML-based scripting language. Imagine a combination
of Ant and JSTL tags that's more general purpose. It's not coupled
to a servlet engine.
Maven TermsMaven Terms
maven.xml
Where you define project-specific goals, as Jelly Scripts
maven.xml is analogous to Ant's build.xml
Plug-in
Where you define reusable, cross-project goals
•Plug-ins represent Maven's major advantage: goal reuse. The actual
Jelly Script goals are defined in a file called plugin.jelly within the
plug-in's folder.
Repository
A folder for storing jar files or, more generally, build artifacts
•Think of the repository as a more structured lib folder. Maven
supports shared network repositories and local repositories.
Dependency A jar file or other artifact upon which your project depends

More Related Content

What's hot

Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
Mike Desjardins
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
Mike Ensor
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2
andyhot
 
maven build certificaton
maven build certificatonmaven build certificaton
maven build certificaton
Vskills
 
Maven basics
Maven basicsMaven basics
Maven
MavenMaven
Maven
feng lee
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
Sandeep Chawla
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
Robert Scholte
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
Tomer Gabel
 
Maven
MavenMaven
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
Robert Burrell Donkin
 
Maven 2 Introduction
Maven 2 IntroductionMaven 2 Introduction
Maven 2 Introduction
Valentin Jacquemin
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
Joao Pereira
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
Smita Prasad
 

What's hot (20)

Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
maven build certificaton
maven build certificatonmaven build certificaton
maven build certificaton
 
Maven basics
Maven basicsMaven basics
Maven basics
 
Apache ant
Apache antApache ant
Apache ant
 
Maven
MavenMaven
Maven
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Maven
MavenMaven
Maven
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
Maven 2 Introduction
Maven 2 IntroductionMaven 2 Introduction
Maven 2 Introduction
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
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 Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 

Viewers also liked

Icefaces Proto Type
Icefaces Proto TypeIcefaces Proto Type
Icefaces Proto Type
ravireddy76
 
From Ant to Rake
From Ant to RakeFrom Ant to Rake
From Ant to Rakejazzman1980
 
Imj2902
Imj2902Imj2902
Maven
MavenMaven

Viewers also liked (6)

Flex Proto Type
Flex  Proto  TypeFlex  Proto  Type
Flex Proto Type
 
Icefaces Proto Type
Icefaces Proto TypeIcefaces Proto Type
Icefaces Proto Type
 
From Ant to Rake
From Ant to RakeFrom Ant to Rake
From Ant to Rake
 
Imj2902
Imj2902Imj2902
Imj2902
 
Maven
MavenMaven
Maven
 
ANT
ANTANT
ANT
 

Similar to Maven

Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
AnkurSingh656748
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management toolRenato Primavera
 
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
Dmitry Bakaleinik
 
Maven
MavenMaven
Java build tools
Java build toolsJava build tools
Java build toolsSujit Kumar
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven
Ankit Gubrani
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
Onkar Deshpande
 
Maven
MavenMaven
What is maven
What is mavenWhat is maven
What is maven
sureshraj43
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
Raghavan Mohan
 
Java tutorial
Java tutorialJava tutorial
Java tutorial
shalsmart12
 
Maven
MavenMaven
Integrating Maven with Eclipse
Integrating Maven with EclipseIntegrating Maven with Eclipse
Integrating Maven with Eclipse
Nikhil Bharati
 
maven
mavenmaven
maven
akd11
 
Build tools introduction
Build tools introductionBuild tools introduction
Build tools introduction
vodQA
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Gourav Varma
 
Build Tools-Introduction (3)
Build Tools-Introduction (3)Build Tools-Introduction (3)
Build Tools-Introduction (3)Manjyot Singh
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
venkata20k
 

Similar to Maven (20)

Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
Apache maven, a software project management tool
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
 
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
MavenMaven
Maven
 
Java build tools
Java build toolsJava build tools
Java build tools
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
P&MSP2012 - Maven
P&MSP2012 - MavenP&MSP2012 - Maven
P&MSP2012 - Maven
 
Maven
MavenMaven
Maven
 
What is maven
What is mavenWhat is maven
What is maven
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
Java tutorial
Java tutorialJava tutorial
Java tutorial
 
Maven
MavenMaven
Maven
 
Integrating Maven with Eclipse
Integrating Maven with EclipseIntegrating Maven with Eclipse
Integrating Maven with Eclipse
 
maven
mavenmaven
maven
 
Build tools introduction
Build tools introductionBuild tools introduction
Build tools introduction
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Build Tools-Introduction (3)
Build Tools-Introduction (3)Build Tools-Introduction (3)
Build Tools-Introduction (3)
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 

Maven

  • 2. Before ANTBefore ANT  Earlier tool used for build was "make"Earlier tool used for build was "make"  The syntax used to be very crypticThe syntax used to be very cryptic  Maintenance of many make filesMaintenance of many make files
  • 3. ANTANT  ANT is cross platformANT is cross platform  ANT is java basedANT is java based  ANT replaces the make file's difficultANT replaces the make file's difficult syntax with more standardized XMLsyntax with more standardized XML
  • 4. Tasks of a configurationTasks of a configuration and build managerand build manager  Copy, CleanCopy, Clean  Compile, JarCompile, Jar  Jar class filesJar class files  Generate the java docGenerate the java doc  Test and DeployTest and Deploy
  • 5. Disadvantages of ANTDisadvantages of ANT  Generally you have a template with whichGenerally you have a template with which you begin with for a new projectyou begin with for a new project  Ant does not provide convenient ways ofAnt does not provide convenient ways of reuse of code. Most of the targets or buildreuse of code. Most of the targets or build scripts look similar, but one has to resortscripts look similar, but one has to resort to copy paste to reuse the same code.to copy paste to reuse the same code.  Creating custom tasks is a workaround,Creating custom tasks is a workaround, but then it becomes an extra activity tobut then it becomes an extra activity to write and maintain custom tags in ANTwrite and maintain custom tags in ANT
  • 6. Disadvantages of ANTDisadvantages of ANT  The size of the script grows as the numberThe size of the script grows as the number of tasks executed increase and one has toof tasks executed increase and one has to write all this and maintain these complexwrite all this and maintain these complex ANT scriptsANT scripts  Logic and looping structures are notLogic and looping structures are not supported and one has to use custom buildsupported and one has to use custom build tasks for the same. These custom taskstasks for the same. These custom tasks might not be reusable across projects. If youmight not be reusable across projects. If you intend to do that, then one will have to put inintend to do that, then one will have to put in lot of effort to write such tasks. Generallylot of effort to write such tasks. Generally you end up with numerous and redundantyou end up with numerous and redundant task in each project.task in each project.
  • 7. MAVENMAVEN Maven is a high-level, projectMaven is a high-level, project management, build and deploymentmanagement, build and deployment tool from the Apache project that addstool from the Apache project that adds a layer of abstraction above Ant.a layer of abstraction above Ant.
  • 8. Tasks Maven can doTasks Maven can do  Compile your code.Compile your code.  Create Java doc documentation.Create Java doc documentation.  Run unit tests.Run unit tests.  Run source code metrics and analysis.Run source code metrics and analysis.  Create a report detailing violations of yourCreate a report detailing violations of your team's coding standards.team's coding standards.  Create a report of the most recent CVSCreate a report of the most recent CVS commits.commits.  Create a report of the CVS activity, pivoted byCreate a report of the CVS activity, pivoted by file and developer.file and developer.
  • 9. Maven AdvantagesMaven Advantages  Supports common build related tasksSupports common build related tasks  Most of the generic tasks have already beenMost of the generic tasks have already been shipped with maven.shipped with maven.  Most of the task have to be written manuallyMost of the task have to be written manually in case of ant. Maven is standardized. Itsin case of ant. Maven is standardized. Its basically based on POM. POM is the waybasically based on POM. POM is the way one indicates the directory structure toone indicates the directory structure to maven. Once this is done one can executemaven. Once this is done one can execute most of the inbuilt maven goals (equivalentmost of the inbuilt maven goals (equivalent of ant targets).of ant targets).
  • 10. Maven AdvantagesMaven Advantages  Tasks like Compile, Copy, Clean, Jar, JavaTasks like Compile, Copy, Clean, Jar, Java doc ,Test, Deploy can be executed usingdoc ,Test, Deploy can be executed using maven without writing even a single line ofmaven without writing even a single line of script.script.  Produces lot of technical information to trackProduces lot of technical information to track the state of the projectthe state of the project  All the ant tasks are available from insideAll the ant tasks are available from inside your Maven projectyour Maven project
  • 11. Maven GoalsMaven Goals  mvn cleanmvn clean  mvn compilemvn compile  mvn packagemvn package  mvn testmvn test  mvn site:generatemvn site:generate  mvn eclipse:eclipsemvn eclipse:eclipse
  • 12. POMPOM Its a XML file. Describes project directory structure,Its a XML file. Describes project directory structure, project dependencies like jar files. Its a kind ofproject dependencies like jar files. Its a kind of metadata. Once the project is described using POM,metadata. Once the project is described using POM, any of the maven tasks can be invoked. Theany of the maven tasks can be invoked. The pom.xml file is the core of a project's configuration inpom.xml file is the core of a project's configuration in Maven. It is a single configuration file that containsMaven. It is a single configuration file that contains the majority of information required to build a projectthe majority of information required to build a project in just the way you want. The POM is huge and canin just the way you want. The POM is huge and can be daunting in its complexity, but it is not necessarybe daunting in its complexity, but it is not necessary to understand all of the intricacies just yet to use itto understand all of the intricacies just yet to use it effectively.effectively.
  • 13. POMPOM <project xmlns="http://maven.apache.org/POM/4.0.0"<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd">v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion><modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId><groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId><artifactId>my-app</artifactId> <packaging>jar</packaging><packaging>jar</packaging> <version>1.0-SNAPSHOT</version><version>1.0-SNAPSHOT</version> <name>my-app</name><name>my-app</name> <url>http://maven.apache.org</url><url>http://maven.apache.org</url> <dependencies><dependencies> <dependency><dependency> <groupId>junit</groupId><groupId>junit</groupId> <artifactId>junit</artifactId><artifactId>junit</artifactId> <version>3.8.1</version><version>3.8.1</version> <scope>test</scope><scope>test</scope> </dependency></dependency> <dependency><dependency> <groupId>org.apache.maven.plugins</groupId><groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId><artifactId>maven-jar-plugin</artifactId> <version>2.2</version><version>2.2</version> <scope>test</scope><scope>test</scope> </dependency></dependency> </dependencies></dependencies> </project></project>
  • 14. Standard Directory StructureStandard Directory Structure By using the standard conventions theBy using the standard conventions the POM becomes very small and youPOM becomes very small and you haven't had to tell Maven explicitlyhaven't had to tell Maven explicitly where any of your sources are orwhere any of your sources are or where the output should go. Bywhere the output should go. By following the standard Mavenfollowing the standard Maven conventions you can get a lot doneconventions you can get a lot done with very little effortwith very little effort
  • 15. Standard Directory StructureStandard Directory Structure my-appmy-app |-- pom.xml|-- pom.xml `-- src`-- src |-- main|-- main | `-- java| `-- java | `-- com| `-- com | `-- mycompany| `-- mycompany | `-- app| `-- app | `-- App.java| `-- App.java `-- test`-- test `-- java`-- java `-- com`-- com `-- mycompany`-- mycompany `-- app`-- app `-- AppTest.java`-- AppTest.java
  • 16. Unit Testing SupportUnit Testing Support Maven makes it easy for theMaven makes it easy for the programmer to build his test cases andprogrammer to build his test cases and execute them. The support for testexecute them. The support for test cases is build into the maven and onlycases is build into the maven and only thing programmer has to do is put thething programmer has to do is put the test classes in the appropriate directorytest classes in the appropriate directory
  • 17. Protecting Your ResourcesProtecting Your Resources Class files are usually loaded from the classpath.Class files are usually loaded from the classpath. Non-class files (resources) can be loaded from theNon-class files (resources) can be loaded from the classpath as well, using the various getResourceclasspath as well, using the various getResource methods. If you want to keep these resources frommethods. If you want to keep these resources from getting wiped out every time you invoke the cleangetting wiped out every time you invoke the clean goal, you need to store resources outside of thegoal, you need to store resources outside of the classes directory and copy them into the classesclasses directory and copy them into the classes directory as part of the build process. Maven has adirectory as part of the build process. Maven has a goal for this purpose called jar-resources. It doesn'tgoal for this purpose called jar-resources. It doesn't jar anything, it just copies resources to thejar anything, it just copies resources to the target/classes directory. Maven automatically callstarget/classes directory. Maven automatically calls the jar-resources goal when you run the jar goal.the jar-resources goal when you run the jar goal.
  • 18. Protecting Your ResourcesProtecting Your Resources First, you need to tell Maven where your resource files are:First, you need to tell Maven where your resource files are: Add the resources element, as shown below, to POM.xml:Add the resources element, as shown below, to POM.xml: ...... </unitTest></unitTest> <resources><resources> <resource><resource> <directory><directory> ${basedir}/src/conf${basedir}/src/conf </directory></directory> </resource></resource> </resources></resources> </build></build> ...... Place a resource file, say box.properties, in <project_home>/src/conf.Place a resource file, say box.properties, in <project_home>/src/conf. Run the jar goal, which indirectly runs the jar-resources goal: mvn jarRun the jar goal, which indirectly runs the jar-resources goal: mvn jar Look in the target/classes folder. You should see that Maven copied box.propertiesLook in the target/classes folder. You should see that Maven copied box.properties from src/conf to target/classes.from src/conf to target/classes.
  • 19. DependenciesDependencies The dependencies section of the pom.xmlThe dependencies section of the pom.xml lists all of the external dependencies thatlists all of the external dependencies that our project needs in order to build (whetherour project needs in order to build (whether it needs that dependency at compile time,it needs that dependency at compile time, test time, run time, or whatever)test time, run time, or whatever) scope : compile , test , and runtimescope : compile , test , and runtime
  • 21. Repository FeatureRepository Feature  Another interesting feature of Maven is its use of a central repositoryAnother interesting feature of Maven is its use of a central repository to access the .jars needed to build your project . You list what .jarsto access the .jars needed to build your project . You list what .jars and versions you need, and Maven is intelligent enough to go andand versions you need, and Maven is intelligent enough to go and download them for you. When you run Maven for the first time, ordownload them for you. When you run Maven for the first time, or attain a new goal, you will see console output detailing repositoryattain a new goal, you will see console output detailing repository access to download any required .jars. This is a great feature thataccess to download any required .jars. This is a great feature that not only makes Maven easier to use and set up, but also saves younot only makes Maven easier to use and set up, but also saves you a lot of time and the headaches of keeping your own collection ofa lot of time and the headaches of keeping your own collection of dependencies up to date in a local directory or in your source-codedependencies up to date in a local directory or in your source-code control system.control system.  Maven checks the local repository and download the jars, which areMaven checks the local repository and download the jars, which are not available in the local repositorynot available in the local repository..  (~/.m2/repository is the default location(~/.m2/repository is the default location e.g C:Documents and Settingsdarshan.vartak.m2e.g C:Documents and Settingsdarshan.vartak.m2
  • 22. InternationalizationInternationalization <project xmlns="http://maven.apache.org/POM/4.0.0"<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">http://maven.apache.org/xsd/maven-4.0.0.xsd"> ...... <build><build> <plugins><plugins> <plugin><plugin> <groupId>org.apache.maven.plugins</groupId><groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId><artifactId>maven-site-plugin</artifactId> <configuration><configuration> <locales>en,fr</locales><locales>en,fr</locales> </configuration></configuration> </plugin></plugin> </plugins></plugins> ......
  • 23. Maven TermsMaven Terms Project Object Model (POM) An XML file that declaratively describes a project • Basically, the POM is project meta-data. Meta-data includes build, dependency, and general project management information. This information is used by goals. Goal An executable function that acts upon a project • Goals are written in Jelly Script. They can be project-specific or reusable across projects. In either case, they act upon your project. In OOP terms, think of your project and its meta-data as an object and goals as the methods that act upon that project. Jelly Script Executable XML • Jelly is an XML-based scripting language. Imagine a combination of Ant and JSTL tags that's more general purpose. It's not coupled to a servlet engine.
  • 24. Maven TermsMaven Terms maven.xml Where you define project-specific goals, as Jelly Scripts maven.xml is analogous to Ant's build.xml Plug-in Where you define reusable, cross-project goals •Plug-ins represent Maven's major advantage: goal reuse. The actual Jelly Script goals are defined in a file called plugin.jelly within the plug-in's folder. Repository A folder for storing jar files or, more generally, build artifacts •Think of the repository as a more structured lib folder. Maven supports shared network repositories and local repositories. Dependency A jar file or other artifact upon which your project depends