Maven

Sandesh Sharma
Sandesh SharmaSoftware Development Engineer at SCA Technologies em SCA Technologies
Maven
Sandesh Sharma
MAVEN
• What is MAVEN
• Installation
• Components
• Configurations
• Errors and Solutions
• Queries
Maven
“a project management tool”

Reports
Generate a web site
Facilitate communication
Installation
• Step 1. Download Apache Maven
–wget
http://www.apache.org/dist//maven/binaries
/apache-maven-3.0.3-bin.tar.gz
• Step 2. Extract archive
–tar -zxvf apache-maven-3.0.3-bin.tar.gz
• Step 3. Add the M2_HOME environment
variable
–nano .bashrc
–export M2_HOME=/opt/apache-maven-3.0.3
–export PATH=${M2_HOME}/bin:${PATH}
• Step 4. Verify installation of Apache Maven
User-specific Configuration and
Repository
• ~/.m2/settings.xml
• ~/.m2/repository/
Components
Creating A Simple Project
What’s In That
Building A simple Project
Go to directory which contains pom.xml
Maven POM
• Stands for Project Object Model
• Describes a project
– Name and Version
– Artifact Type
– Source Code Locations
– Dependencies
– Plugins
– Profiles (Alternate build configurations)
• Uses XML by Default
– Not the way Ant uses XML
Packaging
• Build type identified using the “packaging”
element
• Tells Maven how to build the project
• Example packaging types:
– pom, jar, war, ear, custom
– Default is jar

<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-training</artifactId>
<groupId>org.lds.training</groupId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
Maven Build Lifecycle
• A Maven build follow a lifecycle
• Default lifecycle

– generate-sources/generate-resources
– compile
– test
– package
– integration-test (pre and post)
– Install
– deploy

• There is also a Clean lifecycle
• Dependencies consist of:

– GAV
– Scope: compile, test, provided (default=compile)
– Type: jar, pom, war, ear, zip (default=jar)

<project>
...
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Maven Repositories
• Dependencies are downloaded from repositories
– Via http

• Downloaded dependencies are cached in a local
repository
– Usually found in ${user.home}/.m2/repository

• Repository follows a simple directory structure

– {groupId}/{artifactId}/{version}/{artifactId}-{version}.jar
– groupId ‘.’ is replaced with ‘/’

• Maven Central is primary community repo
– http://repo1.maven.org/maven2
Defining a repository
• Repositories are defined in the pom
• Repositories can be inherited from parent
• Repositories are keyed by id
• Downloading snapshots can be controlled

<project>
...
<repositories>
<repository>
<id>lds-main</id>
<name>LDS Main Repo</name>
<url>http://code.lds.org/nexus/content/groups/main-repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Dependency Exclusions
• Exclusions exclude transitive dependencies
• Dependency consumer solution
<project>
...
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Optional Dependencies
• Don’t propagate dependency transitively
• Dependency producer solution
• Optional is under used
<project>
...
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Dependency Management
• What do you do when versions collide?
– Allow Maven to manage it?
– Complex and less predictable

– Take control yourself

– Manage the version manually

<project>
• In Java you cannot use both versions
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Using Dependency
Management

<project>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency> <!-- Look ma, no version! -->
</dependencies>
</project>

• Other uses for Dependency Management
– Allowing parent pom to manage versions
– Unify exclusions
Maven
1 de 20

Recomendados

Maven tutorial por
Maven tutorialMaven tutorial
Maven tutorialDragos Balan
1.8K visualizações52 slides
Learning Maven by Example por
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
1.6K visualizações42 slides
Liferay maven sdk por
Liferay maven sdkLiferay maven sdk
Liferay maven sdkMika Koivisto
3.2K visualizações20 slides
Maven Introduction por
Maven IntroductionMaven Introduction
Maven IntroductionSandeep Chawla
21.2K visualizações31 slides
Maven 3 Overview por
Maven 3  OverviewMaven 3  Overview
Maven 3 OverviewMike Ensor
2.7K visualizações22 slides
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks por
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksCIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksICF CIRCUIT
3.2K visualizações50 slides

Mais conteúdo relacionado

Mais procurados

Development Tools - Maven por
Development Tools - MavenDevelopment Tools - Maven
Development Tools - MavenBert Koorengevel
477 visualizações57 slides
Apache maven 2 overview por
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overviewReturn on Intelligence
1.8K visualizações37 slides
Introduction to Maven por
Introduction to MavenIntroduction to Maven
Introduction to MavenMindfire Solutions
962 visualizações22 slides
Introduction to maven por
Introduction to mavenIntroduction to maven
Introduction to mavenManos Georgopoulos
1.2K visualizações24 slides
Note - Apache Maven Intro por
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
2.6K visualizações15 slides
SBT by Aform Research, Saulius Valatka por
SBT by Aform Research, Saulius ValatkaSBT by Aform Research, Saulius Valatka
SBT by Aform Research, Saulius ValatkaVasil Remeniuk
527 visualizações23 slides

Mais procurados(20)

Development Tools - Maven por Bert Koorengevel
Development Tools - MavenDevelopment Tools - Maven
Development Tools - Maven
Bert Koorengevel477 visualizações
Introduction to Maven por Mindfire Solutions
Introduction to MavenIntroduction to Maven
Introduction to Maven
Mindfire Solutions962 visualizações
Introduction to maven por Manos Georgopoulos
Introduction to mavenIntroduction to maven
Introduction to maven
Manos Georgopoulos1.2K visualizações
Note - Apache Maven Intro por boyw165
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
boyw1652.6K visualizações
SBT by Aform Research, Saulius Valatka por Vasil Remeniuk
SBT by Aform Research, Saulius ValatkaSBT by Aform Research, Saulius Valatka
SBT by Aform Research, Saulius Valatka
Vasil Remeniuk527 visualizações
Hands On with Maven por Sid Anand
Hands On with MavenHands On with Maven
Hands On with Maven
Sid Anand6.1K visualizações
Apache Jackrabbit Oak on MongoDB por MongoDB
Apache Jackrabbit Oak on MongoDBApache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDB
MongoDB10.7K visualizações
AWS ElasticBeanstalk Advanced configuration por Lionel LONKAP TSAMBA
AWS ElasticBeanstalk Advanced configurationAWS ElasticBeanstalk Advanced configuration
AWS ElasticBeanstalk Advanced configuration
Lionel LONKAP TSAMBA331 visualizações
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev por Werner Keil
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDevTriple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Werner Keil820 visualizações
Maven for Dummies por Tomer Gabel
Maven for DummiesMaven for Dummies
Maven for Dummies
Tomer Gabel6.3K visualizações
Extending Build to the Client: A Maven User's Guide to Grunt.js por Petr Jiricka
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
Petr Jiricka2K visualizações
Java Builds with Maven and Ant por David Noble
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
David Noble2.4K visualizações
Cloud Foundry Open Tour India 2012 , Keynote por rajdeep
Cloud Foundry Open Tour India 2012 , KeynoteCloud Foundry Open Tour India 2012 , Keynote
Cloud Foundry Open Tour India 2012 , Keynote
rajdeep982 visualizações
Selenium Grid por nirvdrum
Selenium GridSelenium Grid
Selenium Grid
nirvdrum4.2K visualizações
Go Faster with Ansible (PHP meetup) por Richard Donkin
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
Richard Donkin1.4K visualizações
The secret life of a dispatcher (Adobe CQ AEM) por Venugopal Gummadala
The secret life of a dispatcher (Adobe CQ AEM)The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)
Venugopal Gummadala5.7K visualizações
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures por François Le Droff
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructuresMaster Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
Master Chef class: learn how to quickly cook delightful CQ/AEM infrastructures
François Le Droff6.9K visualizações
Ansible por Raul Leite
AnsibleAnsible
Ansible
Raul Leite1.4K visualizações
maven por akd11
mavenmaven
maven
akd11375 visualizações

Destaque

Morte de chávez e a volta da autonomia petrolífera dos eua por
Morte de chávez e a volta da autonomia petrolífera dos euaMorte de chávez e a volta da autonomia petrolífera dos eua
Morte de chávez e a volta da autonomia petrolífera dos euaSilva Gomes
177 visualizações4 slides
Ford bpn show 10-12 por
Ford bpn show 10-12Ford bpn show 10-12
Ford bpn show 10-12Cherie Horrigan-Happy
183 visualizações38 slides
Spring, web service, web server, eclipse by a introduction sandesh sharma por
Spring, web service, web server, eclipse by a introduction sandesh sharmaSpring, web service, web server, eclipse by a introduction sandesh sharma
Spring, web service, web server, eclipse by a introduction sandesh sharmaSandesh Sharma
274 visualizações30 slides
Censimento funghi ospedale Sacile 2013 por
Censimento funghi ospedale Sacile 2013Censimento funghi ospedale Sacile 2013
Censimento funghi ospedale Sacile 2013Franca Pusiol
329 visualizações66 slides
14250 ch2 por
14250 ch214250 ch2
14250 ch2kartikm1991
322 visualizações12 slides
Codigo bdoo por
Codigo bdooCodigo bdoo
Codigo bdooJulio Miron Carrillo
263 visualizações5 slides

Destaque(12)

Morte de chávez e a volta da autonomia petrolífera dos eua por Silva Gomes
Morte de chávez e a volta da autonomia petrolífera dos euaMorte de chávez e a volta da autonomia petrolífera dos eua
Morte de chávez e a volta da autonomia petrolífera dos eua
Silva Gomes177 visualizações
Spring, web service, web server, eclipse by a introduction sandesh sharma por Sandesh Sharma
Spring, web service, web server, eclipse by a introduction sandesh sharmaSpring, web service, web server, eclipse by a introduction sandesh sharma
Spring, web service, web server, eclipse by a introduction sandesh sharma
Sandesh Sharma274 visualizações
Censimento funghi ospedale Sacile 2013 por Franca Pusiol
Censimento funghi ospedale Sacile 2013Censimento funghi ospedale Sacile 2013
Censimento funghi ospedale Sacile 2013
Franca Pusiol329 visualizações
14250 ch2 por kartikm1991
14250 ch214250 ch2
14250 ch2
kartikm1991322 visualizações
Automated code review process por Sandesh Sharma
Automated code review processAutomated code review process
Automated code review process
Sandesh Sharma460 visualizações
OOP and java by a introduction sandesh sharma por Sandesh Sharma
OOP and java by a introduction sandesh sharmaOOP and java by a introduction sandesh sharma
OOP and java by a introduction sandesh sharma
Sandesh Sharma451 visualizações
Service oriented architecture por Sandesh Sharma
Service oriented architectureService oriented architecture
Service oriented architecture
Sandesh Sharma408 visualizações
Levis final por Roney Patil
Levis finalLevis final
Levis final
Roney Patil9K visualizações
Core java by a introduction sandesh sharma por Sandesh Sharma
Core java by a introduction sandesh sharmaCore java by a introduction sandesh sharma
Core java by a introduction sandesh sharma
Sandesh Sharma1.7K visualizações
Stitch, seam ppt por Haji Aman
Stitch, seam pptStitch, seam ppt
Stitch, seam ppt
Haji Aman8.9K visualizações

Similar a Maven

Introduction tomaven por
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
236 visualizações27 slides
Maven por
MavenMaven
MavenSunil Komarapu
215 visualizações46 slides
Maven in Mule por
Maven in MuleMaven in Mule
Maven in MuleAnand kalla
260 visualizações46 slides
Mavenppt por
MavenpptMavenppt
MavenpptSurekha Achanta
840 visualizações23 slides
Maven por
MavenMaven
MavenJyothi Malapati
514 visualizações24 slides
Maven por
MavenMaven
MavenJyothi Malapati
1.7K visualizações24 slides

Similar a Maven(20)

Introduction tomaven por Manav Prasad
Introduction tomavenIntroduction tomaven
Introduction tomaven
Manav Prasad236 visualizações
Maven por Sunil Komarapu
MavenMaven
Maven
Sunil Komarapu215 visualizações
Maven in Mule por Anand kalla
Maven in MuleMaven in Mule
Maven in Mule
Anand kalla260 visualizações
Mavenppt por Surekha Achanta
MavenpptMavenppt
Mavenppt
Surekha Achanta840 visualizações
Maven por Jyothi Malapati
MavenMaven
Maven
Jyothi Malapati514 visualizações
Maven por Jyothi Malapati
MavenMaven
Maven
Jyothi Malapati1.7K visualizações
Maven introduction in Mule por Shahid Shaik
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
Shahid Shaik300 visualizações
How maven makes your development group look like a bunch of professionals. por Fazreil Amreen Abdul Jalil
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
Fazreil Amreen Abdul Jalil945 visualizações
Maven por Rajkattamuri
MavenMaven
Maven
Rajkattamuri222 visualizações
Apache Maven por venkatraghavang
Apache MavenApache Maven
Apache Maven
venkatraghavang461 visualizações
Maven por javeed_mhd
MavenMaven
Maven
javeed_mhd274 visualizações
Maven por AbdulImrankhan7
MavenMaven
Maven
AbdulImrankhan7400 visualizações
Apache maven, a software project management tool por Renato Primavera
Apache maven, a software project management toolApache maven, a software project management tool
Apache maven, a software project management tool
Renato Primavera1.6K visualizações
Maven2交流 por ChangQi Lin
Maven2交流Maven2交流
Maven2交流
ChangQi Lin331 visualizações
4 maven junit por Honnix Liang
4 maven junit4 maven junit
4 maven junit
Honnix Liang693 visualizações
Introduction To Maven2 por Shuji Watanabe
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
Shuji Watanabe1.7K visualizações
Tuscany : Applying OSGi After The Fact por Luciano Resende
Tuscany : Applying  OSGi After The FactTuscany : Applying  OSGi After The Fact
Tuscany : Applying OSGi After The Fact
Luciano Resende984 visualizações
Maven por Shraddha
MavenMaven
Maven
Shraddha416 visualizações
Apache Maven for AT/QC por Volodymyr Ostapiv
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
Volodymyr Ostapiv922 visualizações

Último

Business Analyst Series 2023 - Week 4 Session 7 por
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7DianaGray10
146 visualizações31 slides
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsPriyanka Aash
162 visualizações59 slides
Evaluation of Quality of Experience of ABR Schemes in Gaming Stream por
Evaluation of Quality of Experience of ABR Schemes in Gaming StreamEvaluation of Quality of Experience of ABR Schemes in Gaming Stream
Evaluation of Quality of Experience of ABR Schemes in Gaming StreamAlpen-Adria-Universität
38 visualizações34 slides
LLMs in Production: Tooling, Process, and Team Structure por
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team StructureAggregage
57 visualizações77 slides
Future of Indian ConsumerTech por
Future of Indian ConsumerTechFuture of Indian ConsumerTech
Future of Indian ConsumerTechKapil Khandelwal (KK)
36 visualizações68 slides
Cencora Executive Symposium por
Cencora Executive SymposiumCencora Executive Symposium
Cencora Executive Symposiummarketingcommunicati21
160 visualizações14 slides

Último(20)

Business Analyst Series 2023 - Week 4 Session 7 por DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10146 visualizações
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash162 visualizações
Evaluation of Quality of Experience of ABR Schemes in Gaming Stream por Alpen-Adria-Universität
Evaluation of Quality of Experience of ABR Schemes in Gaming StreamEvaluation of Quality of Experience of ABR Schemes in Gaming Stream
Evaluation of Quality of Experience of ABR Schemes in Gaming Stream
Alpen-Adria-Universität38 visualizações
LLMs in Production: Tooling, Process, and Team Structure por Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 visualizações
"Node.js Development in 2024: trends and tools", Nikita Galkin por Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays33 visualizações
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue por ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue265 visualizações
The Role of Patterns in the Era of Large Language Models por Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 visualizações
The Power of Generative AI in Accelerating No Code Adoption.pdf por Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri39 visualizações
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue por ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue137 visualizações
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue por ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue224 visualizações
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc176 visualizações
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue por ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue152 visualizações
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... por ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue108 visualizações
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... por ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue129 visualizações
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT por ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue208 visualizações
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 por BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada44 visualizações
Qualifying SaaS, IaaS.pptx por Sachin Bhandari
Qualifying SaaS, IaaS.pptxQualifying SaaS, IaaS.pptx
Qualifying SaaS, IaaS.pptx
Sachin Bhandari1.1K visualizações

Maven

  • 2. MAVEN • What is MAVEN • Installation • Components • Configurations • Errors and Solutions • Queries
  • 3. Maven “a project management tool” Reports Generate a web site Facilitate communication
  • 4. Installation • Step 1. Download Apache Maven –wget http://www.apache.org/dist//maven/binaries /apache-maven-3.0.3-bin.tar.gz • Step 2. Extract archive –tar -zxvf apache-maven-3.0.3-bin.tar.gz • Step 3. Add the M2_HOME environment variable –nano .bashrc –export M2_HOME=/opt/apache-maven-3.0.3 –export PATH=${M2_HOME}/bin:${PATH} • Step 4. Verify installation of Apache Maven
  • 5. User-specific Configuration and Repository • ~/.m2/settings.xml • ~/.m2/repository/
  • 9. Building A simple Project Go to directory which contains pom.xml
  • 10. Maven POM • Stands for Project Object Model • Describes a project – Name and Version – Artifact Type – Source Code Locations – Dependencies – Plugins – Profiles (Alternate build configurations) • Uses XML by Default – Not the way Ant uses XML
  • 11. Packaging • Build type identified using the “packaging” element • Tells Maven how to build the project • Example packaging types: – pom, jar, war, ear, custom – Default is jar <?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <artifactId>maven-training</artifactId> <groupId>org.lds.training</groupId> <version>1.0</version> <packaging>jar</packaging> </project>
  • 12. Maven Build Lifecycle • A Maven build follow a lifecycle • Default lifecycle – generate-sources/generate-resources – compile – test – package – integration-test (pre and post) – Install – deploy • There is also a Clean lifecycle
  • 13. • Dependencies consist of: – GAV – Scope: compile, test, provided (default=compile) – Type: jar, pom, war, ear, zip (default=jar) <project> ... <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> </dependencies> </project>
  • 14. Maven Repositories • Dependencies are downloaded from repositories – Via http • Downloaded dependencies are cached in a local repository – Usually found in ${user.home}/.m2/repository • Repository follows a simple directory structure – {groupId}/{artifactId}/{version}/{artifactId}-{version}.jar – groupId ‘.’ is replaced with ‘/’ • Maven Central is primary community repo – http://repo1.maven.org/maven2
  • 15. Defining a repository • Repositories are defined in the pom • Repositories can be inherited from parent • Repositories are keyed by id • Downloading snapshots can be controlled <project> ... <repositories> <repository> <id>lds-main</id> <name>LDS Main Repo</name> <url>http://code.lds.org/nexus/content/groups/main-repo</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>
  • 16. Dependency Exclusions • Exclusions exclude transitive dependencies • Dependency consumer solution <project> ... <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.5.RELEASE</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </project>
  • 17. Optional Dependencies • Don’t propagate dependency transitively • Dependency producer solution • Optional is under used <project> ... <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.5.RELEASE</version> <optional>true</optional> </dependency> </dependencies> </project>
  • 18. Dependency Management • What do you do when versions collide? – Allow Maven to manage it? – Complex and less predictable – Take control yourself – Manage the version manually <project> • In Java you cannot use both versions ... <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.5.RELEASE</version> </dependency> </dependencies> </dependencyManagement> </project>