SlideShare une entreprise Scribd logo
1  sur  19
Maven overview
Samuel Langlois – May 2017
Apache Maven history
• Started by Jason Van Zyl in 2001
o Standardising the build of Apache Turbine
• Version history
o 1.0 in Jul-2004, after loads of betas
o 2.0 in Oct-2005, completely redesigned
o 3.0 in Oct-2010, fully compatible
o 3.5.0 is the latest, released Apr-2017
• Previsouly somewhat controlled by Sonatype
• Strong and stable!
Maven is *not* a better Ant
<project>
<target name="compile">
<javac ...>
</target>
<target name="test">
<junit ..>
</target>
<target name="package">
<jar ..>
</target>
</project>
<project>
<groupId>org.alfresco</>
<artifactId>alfresco-core</>
<version>5.1.0</>
<name>Alfresco Core</>
<dependencies>
<dependency>
<groupId>commons-logging</>
<artifactId>commons-logging</>
<version>1.1</>
</dependency>
</dependencies>
</project>
build.xml pom.xml
Maven is *not* a better Ant
<project>
<target name="compile">
<javac ...>
</target>
<target name="test">
<junit ..>
</target>
<target name="package">
<jar ..>
</target>
</project>
build.xml pom.xml
CODE
<project>
<groupId>org.alfresco</>
<artifactId>alfresco-core</>
<version>5.1.0</>
<name>Alfresco Core</>
<dependencies>
<dependency>
<groupId>commons-logging</>
<artifactId>commons-logging</>
<version>1.1</>
</dependency>
</dependencies>
</project>
DATA
Maven plugins
• Written in Java (MOJO), or ...
• Entry-points are called goals
• Examples:
o Core
 maven-compiler-plugin
 maven-resources-plugin - including filtering
 maven-surefire-plugin - executes tests
o Reporting
 maven-javadoc-plugin
 maven-findbugs-plugin
o Code Generation
 antlr3-maven-plugin
o maven-alfresco-plugin !!
o .......
Configuring a plug-in
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>false</debug>
</configuration>
</plugin>
Maven phases
Phase Default binding for jar packaging
initialize
generate-sources
process-resources resources:resources
compile compiler:compile
generate-test-sources
process-test-resources resources:testResources
test-compile compiler:testCompile
test surefire:test
package jar:jar
pre-integration-test
integration-test
post-integration-test
install install:install
deploy deploy:deploy
Plugging a plug-in
<plugin>
<artifactId>maven-jetty-plugin</artifactId>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals> <goal>run</goal> </goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals> <goal>stop</goal> </goals>
</execution>
</executions>
<configuration>
<port>9876</port>
</configuration>
</plugin>
Maven conventions
• tree layout
o pom.xml
o src
 main
• java
• resources
 test
• java
• resources
o target
• tests are executed as part of the build
Follow the Maven way!
Maven dependency
A dependency (internal or external) is made of:
• mandatory : GAV
o groupId (org.alfresco)
o artifactId (alfresco-datamodel)
o version
 release: 4.1.0
 snapshot: 4.1.0-SNAPSHOT
• optionally:
o scope (compile, test, provided, ...)
o classifier (jdk6, sources, javadocs, ...)
Dependencies are transitive!
• mvn dependency:tree dependency:list
Maven dependency management
mvnlocal Maven repo
~/.m2/repository
Maven Central
http://repo.maven.apache.org/maven2/
mvn install
Maven dependency management
mvnmvn install
Team Repo
Maven Central
http://repo.maven.apache.org/maven2/
local Maven repo
~/.m2/repository
Invoking Maven
• call a phase
o mvn clean install
o mvn test
• call a goal
o mvn surefire:test
o mvn javadoc:javadoc
• Useful switches
o -o : offline
o -U : force check for snapshot updates
o -X : verbose, to check plugin configuration
• Adding command-line params for plugins
o -DskipTests
o -Dtest=MyClassTest
Multimodule builds
• call sub-projects in parent folder
<packaging>pom</packaging>
<modules>
<module>core</module>
<module>web-client</module>
</modules>
• pom inheritance in sub-projects
<parent>
<groupId>...
<artifactId>...
<version>...
</parent>
• Computing the actual pom
mvn help:effective-pom
Maven profiles
• conditional parts in the pom.xml
o plug/unplug a submodule
o run a different set of tests
o test various platforms
o ...
• Triggering a profile
o command line: -Pprofile1,!profile3
o presence/absence of a property
o automatic: JDK, OS, platform, existence of a file, …
IDE integration
• "Old school": Maven generating IDE project
o mvn eclipse:eclipse [-DdownloadSources=true]
o mvn idea:idea
o mvn netbeans:netbeans
• Recommended: IDE directly reading pom.xml
o m2e plugin, included in "Eclipse IDE for Java Devs"
Reporting - Maven site
Reporting - Sonar
Want some more?
• Maven books from Sonatype
https://www.sonatype.com/ebooks
• pom.xml reference
• Maven Plugins reference
o Apache
o Codehaus

Contenu connexe

Tendances

Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaEdgar Silva
 
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)OpenStack Korea Community
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 OverviewMike Ensor
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
 
OpenStack Contribution Workflow
OpenStack Contribution WorkflowOpenStack Contribution Workflow
OpenStack Contribution WorkflowSean McGinnis
 
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get DiagnosticsBoris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get DiagnosticsShapeBlue
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreChef Software, Inc.
 
On HBase Integration Testing
On HBase Integration TestingOn HBase Integration Testing
On HBase Integration TestingAndrewPurtell
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringDonghuKIM2
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)Kenny Gryp
 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltStack
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Simon Boulet
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersJavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersAnton Arhipov
 
Submitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guideSubmitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guideopenstackcisco
 
Jabox presentation
Jabox presentationJabox presentation
Jabox presentationspiddy
 

Tendances (20)

Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and Java
 
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
[2018.10.19] 김용기 부장 - IAC on OpenStack (feat. ansible)
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
Openstack bug list
Openstack bug listOpenstack bug list
Openstack bug list
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
OpenStack Contribution Workflow
OpenStack Contribution WorkflowOpenStack Contribution Workflow
OpenStack Contribution Workflow
 
Dev stacklabguide
Dev stacklabguideDev stacklabguide
Dev stacklabguide
 
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get DiagnosticsBoris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
Boris Stoyanov - Troubleshooting the Virtual Router - Run and Get Diagnostics
 
Vagrant to-aws-flow
Vagrant to-aws-flowVagrant to-aws-flow
Vagrant to-aws-flow
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and more
 
On HBase Integration Testing
On HBase Integration TestingOn HBase Integration Testing
On HBase Integration Testing
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics Monitoring
 
Ex407
Ex407Ex407
Ex407
 
Deep dive networking
Deep dive networkingDeep dive networking
Deep dive networking
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)
 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersJavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainers
 
Submitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guideSubmitting and Reviewing changes lab guide
Submitting and Reviewing changes lab guide
 
Jabox presentation
Jabox presentationJabox presentation
Jabox presentation
 

En vedette (10)

Sonar system
Sonar systemSonar system
Sonar system
 
Alfresco Mavenisation
Alfresco MavenisationAlfresco Mavenisation
Alfresco Mavenisation
 
Sonar Metrics
Sonar MetricsSonar Metrics
Sonar Metrics
 
Sonar
SonarSonar
Sonar
 
Sonar Overview
Sonar OverviewSonar Overview
Sonar Overview
 
SONAR
SONAR SONAR
SONAR
 
Robot PowerPoint
Robot PowerPointRobot PowerPoint
Robot PowerPoint
 
robotics ppt
robotics ppt robotics ppt
robotics ppt
 
Basics of Robotics
Basics of RoboticsBasics of Robotics
Basics of Robotics
 
Robotics project ppt
Robotics project pptRobotics project ppt
Robotics project ppt
 

Similaire à Maven Overview: History, Concepts, and Best Practices

Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsSISTechnologies
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
 
maven
mavenmaven
mavenakd11
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialRaghavan Mohan
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and AntDavid Noble
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyVolodymyr Ostapiv
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2Shuji Watanabe
 
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.
How maven makes your development group look like a bunch of professionals.Fazreil Amreen Abdul Jalil
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
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
 

Similaire à Maven Overview: History, Concepts, and Best Practices (20)

Introduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOpsIntroduction to Maven for beginners and DevOps
Introduction to Maven for beginners and DevOps
 
Ant, Maven and Jenkins
Ant, Maven and JenkinsAnt, Maven and Jenkins
Ant, Maven and Jenkins
 
Maven
MavenMaven
Maven
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
maven
mavenmaven
maven
 
MAVEN
MAVENMAVEN
MAVEN
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Apache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT AcademyApache Maven for SoftServe IT Academy
Apache Maven for SoftServe IT Academy
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
 
Maven basics
Maven basicsMaven basics
Maven basics
 
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.
How maven makes your development group look like a bunch of professionals.
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
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
 

Dernier

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Dernier (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

Maven Overview: History, Concepts, and Best Practices

  • 2. Apache Maven history • Started by Jason Van Zyl in 2001 o Standardising the build of Apache Turbine • Version history o 1.0 in Jul-2004, after loads of betas o 2.0 in Oct-2005, completely redesigned o 3.0 in Oct-2010, fully compatible o 3.5.0 is the latest, released Apr-2017 • Previsouly somewhat controlled by Sonatype • Strong and stable!
  • 3. Maven is *not* a better Ant <project> <target name="compile"> <javac ...> </target> <target name="test"> <junit ..> </target> <target name="package"> <jar ..> </target> </project> <project> <groupId>org.alfresco</> <artifactId>alfresco-core</> <version>5.1.0</> <name>Alfresco Core</> <dependencies> <dependency> <groupId>commons-logging</> <artifactId>commons-logging</> <version>1.1</> </dependency> </dependencies> </project> build.xml pom.xml
  • 4. Maven is *not* a better Ant <project> <target name="compile"> <javac ...> </target> <target name="test"> <junit ..> </target> <target name="package"> <jar ..> </target> </project> build.xml pom.xml CODE <project> <groupId>org.alfresco</> <artifactId>alfresco-core</> <version>5.1.0</> <name>Alfresco Core</> <dependencies> <dependency> <groupId>commons-logging</> <artifactId>commons-logging</> <version>1.1</> </dependency> </dependencies> </project> DATA
  • 5. Maven plugins • Written in Java (MOJO), or ... • Entry-points are called goals • Examples: o Core  maven-compiler-plugin  maven-resources-plugin - including filtering  maven-surefire-plugin - executes tests o Reporting  maven-javadoc-plugin  maven-findbugs-plugin o Code Generation  antlr3-maven-plugin o maven-alfresco-plugin !! o .......
  • 7. Maven phases Phase Default binding for jar packaging initialize generate-sources process-resources resources:resources compile compiler:compile generate-test-sources process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package jar:jar pre-integration-test integration-test post-integration-test install install:install deploy deploy:deploy
  • 8. Plugging a plug-in <plugin> <artifactId>maven-jetty-plugin</artifactId> <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> <configuration> <port>9876</port> </configuration> </plugin>
  • 9. Maven conventions • tree layout o pom.xml o src  main • java • resources  test • java • resources o target • tests are executed as part of the build Follow the Maven way!
  • 10. Maven dependency A dependency (internal or external) is made of: • mandatory : GAV o groupId (org.alfresco) o artifactId (alfresco-datamodel) o version  release: 4.1.0  snapshot: 4.1.0-SNAPSHOT • optionally: o scope (compile, test, provided, ...) o classifier (jdk6, sources, javadocs, ...) Dependencies are transitive! • mvn dependency:tree dependency:list
  • 11. Maven dependency management mvnlocal Maven repo ~/.m2/repository Maven Central http://repo.maven.apache.org/maven2/ mvn install
  • 12. Maven dependency management mvnmvn install Team Repo Maven Central http://repo.maven.apache.org/maven2/ local Maven repo ~/.m2/repository
  • 13. Invoking Maven • call a phase o mvn clean install o mvn test • call a goal o mvn surefire:test o mvn javadoc:javadoc • Useful switches o -o : offline o -U : force check for snapshot updates o -X : verbose, to check plugin configuration • Adding command-line params for plugins o -DskipTests o -Dtest=MyClassTest
  • 14. Multimodule builds • call sub-projects in parent folder <packaging>pom</packaging> <modules> <module>core</module> <module>web-client</module> </modules> • pom inheritance in sub-projects <parent> <groupId>... <artifactId>... <version>... </parent> • Computing the actual pom mvn help:effective-pom
  • 15. Maven profiles • conditional parts in the pom.xml o plug/unplug a submodule o run a different set of tests o test various platforms o ... • Triggering a profile o command line: -Pprofile1,!profile3 o presence/absence of a property o automatic: JDK, OS, platform, existence of a file, …
  • 16. IDE integration • "Old school": Maven generating IDE project o mvn eclipse:eclipse [-DdownloadSources=true] o mvn idea:idea o mvn netbeans:netbeans • Recommended: IDE directly reading pom.xml o m2e plugin, included in "Eclipse IDE for Java Devs"
  • 19. Want some more? • Maven books from Sonatype https://www.sonatype.com/ebooks • pom.xml reference • Maven Plugins reference o Apache o Codehaus

Notes de l'éditeur

  1. "convention over configuration" guarantees success!
  2. First thing that maven downloads is itself! plugins, etc. ("Maven downloads the internet")
  3. Adding a Maven repo for the team to proxy central share internal artifacts between team members share releases with outsiders (until we're on central...)