SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Maven
                              Tips & Tricks
                      Brown Bag Lunch - January 2013




                                    1      Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Lifecycle
                      1. process-resources
                      2. compile
                      3. process-test-resources
                      4. test-compile
                      5. test
                      6. package
                      7. install
                      8. deploy

                                                  2   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Search engines

                      • http://search.maven.org/
                       • search through Maven Central
                      • http://mvnrepository.com/
                      • http://nexus.srm
                       • in house repository
                                         3     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Artifacts naming

                      • groupId:artifactId:[classifier:]type:version



                                             4     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Artifacts naming

                      • groupId:artifactId:[classifier:]type:version
                       • follows package naming convention
                       • reverse FQDN

                                             5     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Artifacts naming

                      • groupId:artifactId:[classifier:]type:version
                       • short explicit names are the best


                                             6     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Artifacts naming

                      • groupId:artifactId:[classifier:]type:version
                       • optional
                       • allows to specify special versions

                                             7     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Artifacts naming

                      • groupId:artifactId:[classifier:]type:version
                       • one of jar,pom,war,ear...
                       • determines the nature of the dependency

                                           8     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Artifacts naming

                      • groupId:artifactId:[classifier:]type:version
                       • version number (dot formatted)
                       • -SNAPSHOT are in development dep.

                                             9     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Project inheritance

                      • Allows to group common configuration
                       • repositories
                       • codestyle...
                      • Ease project understanding

                                         10   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Dependencies
                      • Scopes
                       • compile (default) : required for the app
                       • runtime : only necessary at runtime
                       • provided : available by the container
                       • test : required for testing phase
                       • system : absolute path (avoid this)
                                           11    Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Dependencies


                      • Don’t Repeat Yourself
                      • Make your dependencies consistent


                                          12   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Dependencies

                      • Super POM does the
                        dependenciesManagement
                       • <groupId>, <artifactId>, <version>,
                         <scope>, <exclusions>



                                         13      Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
14   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Dependencies

                      • POMs inherit the Super POM
                       • only use <dependencies>
                       • <groupId>, <artifactId>
                       • specific <scope>

                                         15   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
16   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Dependencies

                      • Plugins follow the same rule
                       • <pluginManagement> in Super POM
                         • common <configuration>
                             Always fix plugins’ versions


                                         17    Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Dependencies

                      • Plugins follow the same rule
                       • <plugin> in children
                         • specific <configuration>

                                           18    Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Properties

                      • Ease dependency upgrade
                       • only one value to update
                      • See all dependencies versions at once

                                           19    Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Troubleshoot

                      • Debug
                       • mvn -X
                      • Work offline
                       • mvn -o | --offline

                                             20   Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Troubleshoot

                      • Get the computed POM
                       • mvn help:effective-pom
                      • Get the dependency tree
                       • mvn dependency:tree

                                         21       Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Clean local repository

                      •   wget https://raw.github.com/CedricGatay/small-
                          scripts/master/groovy/CleanDir.groovy

                      •   groovy CleanDir.groovy

                      •   groovy -DdryRun=false CleanDir.groovy




                                              22     Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13
Resources


                      •   Apache Maven
                            http://maven.apache.org/

                      •   Maven dependency plugin
                            http://maven.apache.org/plugins/maven-dependency-plugin/

                      •   CleanDir groovy script
                            https://raw.github.com/jettro/small-scripts/master/groovy/CleanDir.groovy


                                                           23         Cedric Gatay - c.gatay@srmvision.com   Pulling ITSM together


jeudi 17 janvier 13

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Maven Tips - Lunch break slides

  • 1. Maven Tips & Tricks Brown Bag Lunch - January 2013 1 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 2. Lifecycle 1. process-resources 2. compile 3. process-test-resources 4. test-compile 5. test 6. package 7. install 8. deploy 2 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 3. Search engines • http://search.maven.org/ • search through Maven Central • http://mvnrepository.com/ • http://nexus.srm • in house repository 3 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 4. Artifacts naming • groupId:artifactId:[classifier:]type:version 4 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 5. Artifacts naming • groupId:artifactId:[classifier:]type:version • follows package naming convention • reverse FQDN 5 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 6. Artifacts naming • groupId:artifactId:[classifier:]type:version • short explicit names are the best 6 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 7. Artifacts naming • groupId:artifactId:[classifier:]type:version • optional • allows to specify special versions 7 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 8. Artifacts naming • groupId:artifactId:[classifier:]type:version • one of jar,pom,war,ear... • determines the nature of the dependency 8 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 9. Artifacts naming • groupId:artifactId:[classifier:]type:version • version number (dot formatted) • -SNAPSHOT are in development dep. 9 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 10. Project inheritance • Allows to group common configuration • repositories • codestyle... • Ease project understanding 10 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 11. Dependencies • Scopes • compile (default) : required for the app • runtime : only necessary at runtime • provided : available by the container • test : required for testing phase • system : absolute path (avoid this) 11 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 12. Dependencies • Don’t Repeat Yourself • Make your dependencies consistent 12 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 13. Dependencies • Super POM does the dependenciesManagement • <groupId>, <artifactId>, <version>, <scope>, <exclusions> 13 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 14. 14 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 15. Dependencies • POMs inherit the Super POM • only use <dependencies> • <groupId>, <artifactId> • specific <scope> 15 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 16. 16 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 17. Dependencies • Plugins follow the same rule • <pluginManagement> in Super POM • common <configuration> Always fix plugins’ versions 17 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 18. Dependencies • Plugins follow the same rule • <plugin> in children • specific <configuration> 18 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 19. Properties • Ease dependency upgrade • only one value to update • See all dependencies versions at once 19 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 20. Troubleshoot • Debug • mvn -X • Work offline • mvn -o | --offline 20 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 21. Troubleshoot • Get the computed POM • mvn help:effective-pom • Get the dependency tree • mvn dependency:tree 21 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 22. Clean local repository • wget https://raw.github.com/CedricGatay/small- scripts/master/groovy/CleanDir.groovy • groovy CleanDir.groovy • groovy -DdryRun=false CleanDir.groovy 22 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13
  • 23. Resources • Apache Maven http://maven.apache.org/ • Maven dependency plugin http://maven.apache.org/plugins/maven-dependency-plugin/ • CleanDir groovy script https://raw.github.com/jettro/small-scripts/master/groovy/CleanDir.groovy 23 Cedric Gatay - c.gatay@srmvision.com Pulling ITSM together jeudi 17 janvier 13